You're looking for something like this:
Code:#!/bin/sh if [ x$1 = x ]; then echo "Usage: $0 file1 [file2 file3 ...]" exit 1; fi while [ x$1 != x ]; do for LINE in `cat $1`; do rioutil -a $LINE done shift done
I've written a perl script but I think it would work better if I converted it to bash and ran it that way.
In perl I have something like:
open (DATA,"$path/$in"
@data = <DATA>;
close DATA;
foreach $line (@data){
print `rioutil -a $line`;
}
The idea is to open a file and execute the command for each line in the file.
I can't find out how to open the file in bash or to seperate out the lines.
Could someone give me a pointer?
Dizzy
You're looking for something like this:
Code:#!/bin/sh if [ x$1 = x ]; then echo "Usage: $0 file1 [file2 file3 ...]" exit 1; fi while [ x$1 != x ]; do for LINE in `cat $1`; do rioutil -a $LINE done shift done
[quote author=redhead link=board=9;threadid=3769;start=0#38031 date=1024062204]
You're looking for something like this:
[/quote]Code:#!/bin/sh if [ x$1 = x ]; then echo "Usage: $0 file1 [file2 file3 ...]" exit 1; fi while [ x$1 != x ]; do for LINE in `cat $1`; do rioutil -a $LINE done shift done
Let me see if I understand this right.
The if statement is to check if $1 exists and exits if it doesn't.
for LINE in `cat $1` reads the file $1 line by line and produces the output for each line.
Is that right? If so is the while loop necessary?
Dizzy
[quote author=Dizzybacon link=board=9;threadid=3769;start=0#38036 date=1024063386]
[quote author=redhead link=board=9;threadid=3769;start=0#38031 date=1024062204]
You're looking for something like this:
[/quote]Code:#!/bin/sh if [ x$1 = x ]; then echo "Usage: $0 file1 [file2 file3 ...]" exit 1; fi while [ x$1 != x ]; do for LINE in `cat $1`; do rioutil -a $LINE done shift done
Let me see if I understand this right.
The if statement is to check if $1 exists and exits if it doesn't.
for LINE in `cat $1` reads the file $1 line by line and produces the output for each line.
Is that right? If so is the while loop necessary?
Dizzy
[/quote]
The if [] test to see that there atleast is one argument given, ie the file in question, the while [] will run through every argument given, assuming each one is a file, and the for LINE in `cat..` will execute the command on every line found in the files. Thats basicaly it.
[quote author=Dizzybacon link=board=9;threadid=3769;start=0#38027 date=1024060748]open (DATA,"$path/$in"
@data = <DATA>;
close DATA;
foreach $line (@data){
print `rioutil -a $line`;
}[/quote]
Code:open (DATA, "$path/$in"); while (<DATA>) { print `rioutil -a $_`; } close DATA;
Thanks redhead,
I won't be using more than one argument, so I won't need the while 'while' but I think the other stuff is perfect.
Dizzy
what about xargs?
[quote author=njcajun link=board=9;threadid=3769;start=0#38855 date=1024709348]
what about xargs?
[/quote]
So you're thinking something like:
Code:cat the_file | xargs -n1 -p rioutil -a
Bookmarks