i have this line
my,name,is,john
stored in a file d.sh and i wish to print the line as string..but im getting word by word...have tried this.........
for in $(cat $d.sh);
do
echo $i
done
but this is giving me
my
name
is
john
i have this line
my,name,is,john
stored in a file d.sh and i wish to print the line as string..but im getting word by word...have tried this.........
for in $(cat $d.sh);
do
echo $i
done
but this is giving me
my
name
is
john
use a while loop
while read -r line
do
echo "$line"
done < "yourfile"
thanx a lot ghostdog that was straight forward really appreciate it!
if i have 2 files to compare the lines how do i do it with the While loop
say file 1 has
my name is john
file2
my name is jon
i want to compare if the lines in each file are the same
have tried
cat 'file.1' | while read line;
do
c=$line
cat 'file.2' | while read line
do
d=$line
if test "$c" != "$d"
then echo $c is different
fi
done
done
prints continously
if all you want is to compare lines in 2 files , you can use diff. check the diff man page
thanx mate i have been using the diff , cmp, comm and patch but with the files i was doing include an md5sum but still the outcome isnt true thus trying to do it manually with the while loop......if u get a chance just correct me in the While loop
you could just show some sample input files.
or add the Internal Field Seperator to ur For loop code
IFS=$'\n'