![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| cut last line of a word | bullz26 | Shell Programming and Scripting | 2 | 03-18-2008 08:42 AM |
| how to move word by word on command line | pbsrinivas | UNIX for Dummies Questions & Answers | 1 | 11-23-2007 03:17 AM |
| Need to replace the first word of a line if it occurs again in the next line(shell) | geeko | Shell Programming and Scripting | 1 | 09-25-2007 07:15 AM |
| put each word in new line - sed or tr | hemangjani | Shell Programming and Scripting | 3 | 09-13-2006 11:06 AM |
| Can a shell script pull the first word (or nth word) off each line of a text file? | tricky | Shell Programming and Scripting | 5 | 08-17-2006 03:29 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
use a while loop
Code:
while read -r line do echo "$line" done < "yourfile" |
|
#3
|
|||
|
|||
|
Quote:
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 |
|
#4
|
|||
|
|||
|
if all you want is to compare lines in 2 files , you can use diff. check the diff man page
|
|
#5
|
|||
|
|||
|
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
|
|
#6
|
|||
|
|||
|
you could just show some sample input files.
|
|
#7
|
|||
|
|||
|
or add the Internal Field Seperator to ur For loop code
IFS=$'\n' |
|||
| Google The UNIX and Linux Forums |