Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Process line from file -Cshell scr
Name: Shailesh Date: May 22, 2003 at 05:21:21 Pacific OS: UNIX CPU/Ram: SPARC
Comment:
Hi,
I want to read a file in a C shell script and process all the words of each line as a command set.
something like this
read line from file get the first word from line and assign it to a variable get the second word and assign to another variable process based on these variables. read the second line from file ... ....
Name: twisgabak Date: May 26, 2003 at 19:39:24 Pacific
Reply:
Hi!
try this:
## start FILE_NAME=test.txt
#code to change separator(see note)
for value in `cat $FILE_NAME` do echo $value done
## end
For the separator, I can't remember the reserved shell variable, but usually it is set to space, tab and \n. But you can modify it so the for loops one line at the time(if you let only \n in this variable). Check into the shell documentation (Unix in a nutshell from O'Reilly is a good book for that)...
Summary: hi, i need to pick up a line from a file and store it in a variable.i dont know the number of lines that the file contains...so i cannot specify it by a linenumber. i need to continue this till the la...
Summary: hai, i want to remove duplicate lines from any part of the file...uniq command is used to remove only the adjacent duplicate lines...if we use sort command with -u option it removes duplicate lines ...