ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
what it's doing is loading all the values into the variable.
what I need to do is to load one record at a time and through the use of a If stmt, check if that is the record that I am looking for.....if not would then move to the next record.....until it find it or hit the end of the file
var=calc #You store the string that u want to compare
while read line
process=`echo "$line" | cut -f1 -d " "`
if [ "$process" = "$var" ]
echo "The line is: $line" #Do whatever you want
done < test.dat
Originally posted by cracauer
cat foobar.txt | while read foo ; do
set -- $foo
echo $var1 comes with $var2
OK, that's just great... now I have to rewrite all my shell-scripts!
It is neat tricks like this that makes your shell-scripting evolve!
Too bad set doesn't come with a man page... Do you know any resource where I can read more about this?
Being a shell builtin, set is documented in the shell man page:
set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
Without options, the name and value of each shell variable are
displayed in a format that can be reused as input. The output is
sorted according to the current locale. When options are speci-
fied, they set or unset shell attributes. Any arguments remain-
ing after the options are processed are treated as values for the
positional parameters and are assigned, in order, to $1, $2, ...
Well, I'm non native english too, and agree I would have never find this use by reading the manual page. I discovered the "set" feature a long time ago, probably while reading someone else's script.
However, the manual pages serve most as reference and usually only formally describe the command, function or file functionality and usage and is not to replace a tutorial.
It is true that the "examples" section is frequently very light if not missing in manual pages, but it would be impossible for a such complex and powerfull tool like a shell is to exhaustively describe every use, tip or trick ...
Originally posted by jlliagre It is true that the "examples" section is frequently very light if not missing in manual pages, but it would be impossible for a such complex and powerfull tool like a shell is to exhaustively describe every use, tip or trick ...
So true... But this is what the forums are for, right?
Sharing tips/tricks and helping eachother out.
I can only imagine how hard it must have been learning Linux before the Internet was as common as it is today.