Re: access nth argument list in a file
From: Ed Morton (morton_at_lsupcaemnt.com)
Date: 03/21/05
- Next message: zippy747: "Re: access nth argument list in a file"
- Previous message: zippy747: "access nth argument list in a file"
- In reply to: zippy747: "access nth argument list in a file"
- Next in thread: zippy747: "Re: access nth argument list in a file"
- Reply: zippy747: "Re: access nth argument list in a file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 21 Mar 2005 16:28:30 -0600
zippy747 wrote:
> for include in ${includes}
> do
>
> done
>
> This accesses the last "includes" argument list in a file. How would i
> access the nth "includes" argument list in a file?
>
> i.e. the code above will iterate through "e f g h" but how do i
> iterate through "a b c d"?
>
> includes="a b c d"
> includes="e f g h"
>
> Thanks,
> -zip
>
If "file" contains
a b c d
e f g h
then this might be what you want:
while read includes
do
for include in $includes
do
echo "$include"
done
done < file
If you want to test for the Nth entry, just add a counter or use sed or
awk to pull out the Nth entry, e.g. in awk:
awk 'NR==7' file
would print the 7th line of "file".
If the above doesn't do what you want, describe what you want.
Ed.
- Next message: zippy747: "Re: access nth argument list in a file"
- Previous message: zippy747: "access nth argument list in a file"
- In reply to: zippy747: "access nth argument list in a file"
- Next in thread: zippy747: "Re: access nth argument list in a file"
- Reply: zippy747: "Re: access nth argument list in a file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]