1825002 Members
2722 Online
109678 Solutions
New Discussion юеВ

Re: Script...

 
SOLVED
Go to solution

Script...

Hi, All!

I want write script for command:
#dcNLS *.err,
where *.err - 16 files.
How can write it for processing this files? What syntax for processing of group files?
Thanx in advance. Oleg
6 REPLIES 6
Robin Wakefield
Honored Contributor

Re: Script...

Oleg,

Lots of ways, in a ksh, try this:

for file in *.err ; do
dcNLS $file
done

Rgds, Robin
Sachin Patel
Honored Contributor

Re: Script...

Hi Oleg,

#!/bin/sh
cd /destination directory
for FILE in *.err; do
command $FILE
done

Sachin
Is photography a hobby or another way to spend $

Re: Script...

Hi!
In case $file will be processing all files in directory ?
But I need processing only group of files. How I can to specify in script which files need process?
Oleg.
Robin Wakefield
Honored Contributor

Re: Script...

Hi Oleg,

The syntax:

for file in *.err ; do
...
done

will loop round all the files ending in .err, processing them **one at a time**. If you wish to specify a different group of files, you will need to work out how these are identified.
You can put in a multiple list, or have them listed in a file, i.e..

for file in *.err *.log *.txt ; do
command $file
done

cat filename | while read file ; do
command file
done

Please provide more information if this is not what you mean.

Thanks and regards, Robin.

Re: Script...

Hi, Robin!
Thanx for answer a excuse me for late reaction.
I did script:
cat list | while read list; do
dcNLS *.err > kkk
done
where list - file with list of files that need to process.
But script process all *err.files. :(
Where My mistake?
Excuse me Robin? but can "present" link at description for command that use in scripts. At russian I didnt saw, at english I didnt know where..

Oleg
Robin Wakefield
Honored Contributor
Solution

Re: Script...

Hi Oleg,

Your script should read:

cat list | while read file; do
echo Processing $file ...
dcNLS $file >> kkk # NOT -> dcNLS *err <-
done

I left off the "$" in my previous answer - sorry. The echo statement will let you know which file it is processing. Use a double ">" for redirection otherwise it will get overwritten each time.

Hope this helps, Robin.