HI Guys,
I have a data in a file in the below format
45783
23457
23556
54584
Now i want to convert this data into the below format
reader='45783' or
reader='23457' or
reader='23556' or
reader='54584'
Please help how to convert as i am applying loop but not able to get the data in the exact format.
Try this...
sed "s/.*/read='&' or/g;$ {s/or//g}" infile
--ahamed
while read x; do echo "reader='$x' or"; done < inputfile
sed -e "s/^/reader='/g" -e "s/$/' or/g" inputfile
Thanks ahmed..
Can you elaborate how it's working.??
s/.*/read='&' or/g
Replace everything with the format you want. '&' will have the entire search string.
$ {s/or//g}
You dont want the "or" at the end of the last line right? So, when the last line is found remove the "or" which was placed with the previous command. "$" stands for the last line here and not end of each line.
--ahamed
Oh yeah, the last line doesn't contain an 'or' at the end. An alternative using Perl 
perl -ne 'chomp;(eof)?print "reader='\''$_'\''\n":print "reader='\''$_'\'' or\n"' input