shell script problem
matthew at FreeBSD.org
Sun Dec 23 09:57:27 UTC 2012
On 23/12/2012 09:43, Polytropon wrote:
> On Sun, 23 Dec 2012 10:34:34 +0100, Polytropon wrote:
>> First, the lines with "read" have to be:
>> cat /foo/bar.txt | while read $LINE1
>> cat /foo/bar/foo/bar.txt | while read $LINE2
>> Reason: $LINE1 and $LINE2 will be evaluated here, they are "empty
>> string", causing "read" to throw an error.
> Excuse me - I made a mistake! Of course those two lines
> have to be:
> cat /foo/bar.txt | while read LINE1
> cat /foo/bar/foo/bar.txt | while read LINE2
> The $ infront of the variable names have to be removed.
> The variable _name_, not its content, has to be provided
> to "read" as a parameter.
> The script so far:
> cat foo.txt | while read LINE1
> cat bar.txt | while read LINE2
> if [ "$LINE1" = "$LINE2" ]; then
> echo "Current value of sw is : " $sw
> echo "Value of sw is : " $sw
> if [ "$sw" = "0" ]; then
> echo "DO SOMETHING!"
Hmmm.... I'd just like to draw your attention to the comm(1) program,
which lets you find lines common to two files, or only in one or other
of a pair of inputs, very easily. The only slight gotcha is that the
input files have to be sorted.
Dr Matthew J Seaman MA, D.Phil.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 266 bytes
Desc: OpenPGP digital signature
More information about the freebsd-questions