I have a text file like:
The name of the project = "Symbion centrifuge"
The name of the subsytem = "motor demon"
now i would like to read the string after the = into a variable to write it to another file.
later use like:
sed s/'PROJECTNAME'/"$projectname"/ <header.tex >temp
in $projectname i would like to have "Symbion centrifuge".
I have problems to do that...
Please help me!
vivelafete
look up awk and setting the delimiter (FS)
try this
awk -F"=" '{print $2}' filename
or
awk -F"=" '{print $2}' filename > outputfile.txt
frans
December 10, 2009, 2:13pm
4
My first (success after a lot of errors!) try with awk (:
awk 'BEGIN {FS="="} {print $2}' header.tex | sed 's/"//g'
To put it in a variable:
VARIABLE=$(awk 'BEGIN {FS="="} {print $2}' header.tex | sed 's/"//g')
read line < infile
projectname="${line#*= }"
cat filename |sed 's/.*="\(.*\)".*/\1/' > output.txt
sed -n '1s/.*= //p' infile
while IFS="=" read a b
do
echo $a
echo $b
done <"file"
Misread your post, I thought you wanted to get rid of the double quotes around the value as well, since it appears you don't want to do that, this should do the job:
sed 's/.*=\(.*\)/\1/' < <inputfile>