Search Results

Search: Posts Made By: macastor
1,213
Posted By Scrutinizer
Yes you would need to leave out the curly...
Yes you would need to leave out the curly brackets too, that belong to the shell variables. Try:
sed "/RED/s/^\(.\{101\}\).\{7\}/\1BLUE/"
2,776
Posted By ctsgnb
To make it easier and safer, maybe you sould...
To make it easier and safer, maybe you sould consider formating your file with a separator at first (here an example with colon ":" as separator)

sed 's/PO BOX [0-9][0-9]*/:&:/;s/[^ ][^...
2,776
Posted By CarloM
You can pad numbers with a format specifier like...
You can pad numbers with a format specifier like %03d, but iirc it doesn't work with strings - check the man page(s).
1,554
Posted By jayan_jay
just a try .. ;) $ echo $a "JERRY SMITH" ...
just a try .. ;)

$ echo $a
"JERRY SMITH"
$ echo $b
filename
$ x=$(sed -n "/$a/p" $b)
$ echo $x
"JERRY SMITH"
$
1,554
Posted By agama
You need to quote $a so that it is passed as a...
You need to quote $a so that it is passed as a single token to grep:


x=`grep -c "$a" "$b"`


Putting the quotes as a part of the string that is assigned to the variable does not have the...
1,505
Posted By Corona688
That's not a very good solution. Try some of the...
That's not a very good solution. Try some of the others given to you.
1,505
Posted By verdepollo
Perhaps something like this? if [ -f...
Perhaps something like this?

if [ -f /path/to/file ]; then echo 1; else echo 0; fi
1,505
Posted By yazu
test -e /etc && echo exists exists test -f...
test -e /etc && echo exists
exists

test -f /etc && echo file

echo $?
1
2,759
Posted By Shell_Life
You asked to add/insert a string, this way the...
You asked to add/insert a string, this way the original data is incremented by the string and thus shifted.

If you do not want to have the data shifted, then you want to replace:
sed...
Showing results 1 to 9 of 9

 
All times are GMT -4. The time now is 03:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy