Need to make a single line of code change to a huge file.
SED is the way to do it but I think im getting lost in the land of escapes and crazyness.
Need to replace the following
if [[ "${EXAMPLE1}" == .* ]]; then
With:
if [ "${EXAMPLE1}" != "" ]; then
Ive tried repeatedly and will carry on trying :) but if one of you lot could throw us a bone itd be much appreciated.
Wussed out in the end as it was the only occurance of it in the entire gazillion lined file, I went for this.
sed -i s/ \=\= \.\* / \!\= \" \" / filename
:) Works... as it just needed to change the test not what it was checking.
Had issues with the {} braces as well ive no idea but I think they are used to group ranges and patterns in regexp.
sed -e s/\[\[ "\${EXAMPLE1}" == \.\* \]\]/[ "${EXAMPLE1}" != "" ]/ filename
that works for me.
{ } are used to define the number of times the previous character occurs
Example:
/[0-9]{1,3}/
Means there must be minium of 1 and max of 3 numeric chars or...
/[0-9]{3}/
Means there must be exactly 3 numeric chars
Doesnt work here as the brackets are part of the string to be checked, not used as a regex.
Its pretty much a straight pattern match.
Quote from: M3ta7h3adDoesnt work here as the brackets are part of the string to be checked, not used as a regex.
Its pretty much a straight pattern match.
But it knows cos its got non digits in.