* Jack Barnett <[EMAIL PROTECTED]> writes:
> I am not very good with bourne shell scripts, but above you
> increment LOOP with
> LOOP=$[LOOP + 1]
> why won't it work if you do a
> FILE=$[FILE + 1]
Because the contents of FILE is '$1' which is expanded to the first
positional parameter of the command line. The command line as I
stated was 'scriptname *', which expands to all the files in the
current directory.
So, for example, if the directory contains these files...
aaa, bbb, ccc, ddd & eee
scriptname * would expand to...
scriptname aaa bbb ccc ddd eee
and the contents of FILE is $1 which is 'aaa'. What I want to do is
increment FILE from $1 (aaa) to $2 (bbb), then $3 (ccc) and so on.
What you have suggested (FILE=$[ FILE +1 ]) the first time through the
loop FILE would contain 'aaa', but the next time it would contain '1',
then '2' and so on.
> Also, isn't this statement clobbing your $FILE?
> cat $FILE | tr "\r" "\n" > $FILE
Nope, Linux handles it in its stride. :-)
> If the filenames are numbered 1, 2, 3, 4; can't you just use the
> LOOP variable?
Unfortunately, the files aren't named 1 2 3 4 etc. With what I want
to do, I won't know the filenames beforehand.
> Here is a quick perl script that might work for you
> #!/usr/bin/perl -w
> $directory = "./";
> @ls = `ls $directory`;
> foreach(@ls)
> { chop($_);
> system ("cat $_ | tr \"\r\" \"\n\" > $_.output");
> }
That looks interesting, I can't comment on it because I don't know the
first thing about perl scripting. :)
Thanks for your help
===========================
Want to really learn Linux?
... Install Slackware
===========================
--
|---<Regards, Steve Youngs>-------------------------------------|
| Genius is the ability to |
| reduce the complicated to the simple |
|------------------------------------<[EMAIL PROTECTED]>---|
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.linux-learn.org/faqs