the problem is probably the two single quotes after "-i". If i remember correctly "-i" means "change the file in place, instead of writing the results of the substitions to another file". If this is the case the '' is treated as the regex expression and the regex is treated as filename.
It is not a good idea to use the "-i" switch anyways, because firstly you run the risk of changing your original with some unwanted substitution and secondly the "-i"-switch is not supported by most sed-versions and hence your command is not very portable.
My suggestion is to write it this way:
Once you are satisfied with the outcome displayed you can replace "| more" by some redirection to a file. Use "mv" to overwrite the original with this file if you want to do so.
@a_ba:
Quote:
This looks like your variables aren't being expanded at all. Check the spelling of your variables (even capitalization counts, "$a" and "$A" is NOT the same).
A second possible problem is variable scope: Maybe the variables are not set in the environment you (try to) use them but another. Try this to make sure this is not the problem:
Hi
I have a variable whose value is like this
i=/test/test1/test2/myfile.cd.070505123457
i would like to have the value of myfile.cd stored into another variable
my attempt is
test=${i##*/} ;echo $test ##and i get
myfile.cd.070505123457
since what i wnat is myfile.cd i try this... (19 Replies)
My specific goal: automatically edit a Makefile variable's (EXTRAVERSION)
value in a kernel Makefile.
So, I have a shell script that takes one parameter, a version string:
buildkernel.sh 2.6.18.21.7-custom
In the script, I assign the parameter to K_VER:
K_VER="2.6.18.21.7-custom"... (2 Replies)
Hello,
I wonder if it is possible to pass and use variables from shell environment into sed or awk. I am trying to achieve something similar to the following using sed or awk:
var=some_regular_expression
grep "$var" filename # Will extract lines from filename
The following code,... (3 Replies)
Hi ,
I am stuck up in the below scenario:-
I need to read a file name (eg A.txt) name frm another file (eg B.txt) and then I need to search for a particular expression in A.txt and substitute it with another expression.
How can I use SED inside SHELL Scripting and command prompt as well to... (1 Reply)
Hi,
I have to read a file and translate the contents including substituting the variables if any and write to another file without using sed or awk.
For ex:-
inputfile.txt
-----------
servername=$SERVER
application=$APPL
outputfile.txt
------------
servername=actual server name... (2 Replies)
Hi,
I'm using an array that contains compiler FLAGS
that need to be executed either before ./configure
or after the main 'make' command.
example of array containing compiler flags.
-------------------------------------------------
FLAGS="CFLAGS=\"-arch x86_64 -g -Os -pipe... (7 Replies)
hi guys,
The following command doesn't seem to work in my shell script:
tag=$(sed -n '/${line}/ s/.*\.*/\1/p' myfile.txt)
When i replace the ${line} with an actual value, it works fine.
So, how do i use the ${line} in this sed command?
Thanks in advance,
Zaff (2 Replies)
I have a file with some numbers having single quotes around them which I want to remove.
i.e. '923930' -> 23930
If it can be done without using sed thats fine. I have tried with sed but can't think how to replace this pattern on only the numbers (13 Replies)
hello!
I am trying to use sed to copy specific set of lines from a file for which the starting and ending line numbers of the lines to be copied are stored in shell variables. How can i copy those lines?
if the input_file is something like this
and if the following is the script
a=2
b=4... (4 Replies)
To all geeks,
What I want to achieve:
1. Accept two filenames from user and store the filenames in two variables (FILE1 and FILE2)
2. Check if files exisits. If doesn't, then exit
3. If files exist, look for a particular string in both files
4. If the string exists, then change the... (8 Replies)