How to read a multiple lines from a file n executing them?
Hi all,
I am just trying to read the contents of a file. basically this file has a list of dat files. then i want to access these dat files n execute a script on them one by one using a loop.
i hav e written like this
Please help me out.
edit by scottn: Moved from AIX sub-forum (it's not an AIX-specific question
Last edited by Scott; 12-17-2010 at 08:12 AM..
Reason: Replace QUOTE tags with CODE tags
Thanx anurag 4 ur help.
No basically I am trying to delete the control M characters from around 100 files in a directory.I am using the con.ksh script to delete cntrlM characters in a single file. But how to do it in a loop.
I have tried the following script too. but its not working also
Quote:
j=0 ls -l | cut -c 58-88 > file1.txt cat file1.txt | while read a
do
echo "value of a $a"
arr1[j]=$a
convert.ksh ${arr1[j]}
j=`expr $j + 1`
echo "working"
done
It looks like you are just passing all files names to convert.ksh script one by one in a loop. Here variables a and arr1[j] have file name value in it.
If so, same is happening in my script. each file ($file variable) is being passed to con.ksh (change it to convert.ksh).
But the issue is not resolved.
I think you could not get it. I am trying to pass the filenames but those filenames are the files of a directory. So i am trying to extract the files names only by using
ls -l | cut -c 58-88 > file1.txt .
Now this file1.txt contains all the filenames only in column manner.
Now I am trying to execute the files by selecting the names of the files from file1.txt.
Here all files under current dir will be passed to convert.ksh one by one.
If condition can be removed if current dir contains only FILES, not subdirectories.
This User Gave Thanks to anurag.singh For This Post:
anurag.singh is correct in what is said. The question we have to be clear on is why you want to
I assume that this is so you get just the names of the files from an ls -l, but this is just the same as output from ls sent to a file or ls -1 (flag is minus one) to be used in a loop as described.
So, what are you trying to get? If it is just files from a directory, you might also confuse yourself if you write the temporary file there too. Editing the file with con.ksh mid program when that is the input file might have unpredictable results too.
You also run the risk of having a file that is longer than the 31 characters you are limiting this to. If you have a file called this_is_a_very_long_name_for_a_file, then you would try to run
and presumably get an error meaning file not found.
Another way to approach this is to use the find command. As such, you can exclude links, directories, pipe files etc. by specifying you only want regular files:
This looks in the current directory (the dot) for a regular files (-type f) and then executes con.ksh with each as an arguement (-exec con.ksh {} \ The trailing \; marks the end of the -exec part of the command and the find will error if it is missing.
I hope that this is useful, but please write back if this I have missed the point.
GM,
I have an issue at work, which requires a simple solution. But, after multiple attempts, I have not been able to hit on the code needed.
I am assuming that sed, awk or even perl could do what I need.
I have an application that adds extra blank page feeds, for multiple reports, when... (7 Replies)
Hello All,
I have a file like below....
dn: cn=user1,ou=org,o=org
cn=user1
uid=user1
cn=user2,ou=org,o=org
cn=user2
uid=user2
cn=user3,ou=org,o=org
cn=user3
cn=user33
uid=user3
cn=user4,ou=org,o=org
cn=user4
uid=user4 (6 Replies)
Hi
Am having file.ksh as below
wc -l file1.txt
wc -l file2.txt
wc -l file3.txt
wc -l file4.txt
i want all the commands in this file to execute in same time
please help
Thanks in advance (1 Reply)
I am trying to create a script which will read 2 files and use the lines of file 1 for each line on file 2.
here's my sample code
cat $SBox |
while read line
do
cat $Date |
while read line
do $SCRIPTEXE <line from first file> $2 <line from 2nd file>
... (12 Replies)
I have one long line text with semicolon used as separator between values in that line. Now, I want to separate the line into multiple line right after every 29th field.
example input line:
... (1 Reply)
I have one long line text with semicolon used as separator between values in that line. Now, I want to separate the line into multiple line right after every 29th field.
example input line:
... (2 Replies)
Hello All,
i am a newbie and need some help when reading a csv file in a bourne shell script. I want to read 10 lines, then wait for a minute and then do a reading of another 10 lines and so on in the same way. I want to do this till the end of file.
Any inputs are appreciated
... (3 Replies)
Hi All,
Does anyone know how to read multiple lines from standard input into an array and then iterate a loop for all the lines read. Below is an example pseudocode:
I need the below filenames to be read by the script into an array or something similar:
And then in the script, I... (9 Replies)
Could any one tell me how to read and match multiple lines in perl? Did this code below still work in this situation?
while (<FILE>) {
if (/ /) {
}
}
Thanks a lot! (5 Replies)