Sponsored Content
Top Forums Shell Programming and Scripting List creation - Grep a line in a file with a script name Post 302902866 by member2014 on Thursday 22nd of May 2014 01:52:47 PM
Old 05-22-2014
List creation - Grep a line in a file with a script name

Hi,
I have a list file which has script names in them. Some scripts take lists as parameters which inturn have script names. This is basically for sequencing the job run.

Eg: List1:
Code:
test1.ksh
test2.ksh test2.lst
test3.ksh test3.lst
test4.ksh

test2.lst:
Code:
test21.ksh
test23.ksh
test23.ksh

test3.lst:
Code:
test31.ksh
test33.ksh
test33.ksh

I need to write code to create one master list from this which will look like:
Code:
test1.ksh
test21.ksh
test23.ksh
test23.ksh
test31.ksh
test33.ksh
test33.ksh
test4.ksh

I am trying to grep every line in List1, if it contains .lst get the list file name and echo the contents to create the master list.
It gives me an error as the line contains a script name and the script is not in the directory.
Is there a wat I can grep a line in a file which contains a script name?

Code:
#!/bin/ksh
while read line
do
   echo $line
   sublst_name1=`echo $line | cut -d " " -f2`
   echo $sublst_name1
   lst_cnt=$(grep -i .lst $sublst_name1 | wc -l)
   echo $lst_cnt
done <"$lst_file"

output:
Code:
test1.ksh
test1.ksh
grep: can't open test1.ksh
0
test2.ksh test2.lst 
test2.lst
2
test3.ksh test3.lst 
test3.lst
2
test4.ksh
test4.ksh
grep: can't open test4.ksh
0

Thanks in advance for the help.

Moderator's Comments:
Mod Comment Please use code tags!

Last edited by radoulov; 05-22-2014 at 03:28 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Creation and Transfer of TAR file from one machine to another Using UNIX script

Hi, I want to create unix script such that it should run on machine A, it should run TAR commands on machine B and copy that TAR to machine C. Is it possible? Thanks Rahul (2 Replies)
Discussion started by: rahuljadhav
2 Replies

2. Shell Programming and Scripting

Creation of output file from list of file

Hi Guru's, Eventhough I know basic shell scripting, Iam not an expert. Can any one help me to get a logic/answer for the below requirement: I've to create an output file "outputfile.txt" from many datafiles (ex: abc.dat, xyz.dat). Header record layout for "outputfile.txt" should be... (7 Replies)
Discussion started by: ganapati
7 Replies

3. Shell Programming and Scripting

Creation of script,if the data file have more than one entry!!!

1.Daily there will be 14 files in the data directory 2.someday's the 14 files receive more than once r twice with different time stamps....we need to chk the count of the file and if the count of the file is two.we need to combine the both the files. 3. if any duplicate data is there just... (1 Reply)
Discussion started by: bobprabhu
1 Replies

4. Shell Programming and Scripting

how to grep a file in list

hi all, for an example: In a file out.txt contains: /export/home/raghu/bin/debug_serverLog_apache_20090626_0625.txt How to grep or cut the value as "debug_serverLog_apache_20090626_0625.txt" or i want only the output as "debug_serverLog_apache_20090626_0625.txt" pls advice me (3 Replies)
Discussion started by: raghur77
3 Replies

5. Shell Programming and Scripting

Avoid file creation in a script...achive same result

Guys following lines help me in getting numbers from PID column ,to be thrown into first column of a CSV file. COLUMNS=2047 /usr/bin/ps -eo pid,ppid,uid,user,args | grep -v "PID" > /tmp/masterPID.txt cat /tmp/masterPID.txt|while read line do PID=`echo $line|awk '{print $1}'` echo "$PID"... (4 Replies)
Discussion started by: ak835
4 Replies

6. Shell Programming and Scripting

Grep by range of date from file creation in directory

Hi Expert, Need your scripting and finding data so that it help me to find the culprit of this memory usage error. Data provided here is a sample. Process Snapshot directory: /var/spool/processes-snapshot webdev9o9% pwd /var/spool/processes-snapshot webdev9o9% ls -lrct -rw-r--r-- ... (3 Replies)
Discussion started by: regmaster
3 Replies

7. Shell Programming and Scripting

File system creation script on AIX 6.1 using while loop

#!/bin/sh echo "VG: " read VG echo "LP: " read LP echo "SAP: " read SAP echo "NUM: " read NUM echo "SID: " read SID while ]; read VG LP SAP NUM SID ; do mklv -y $SAP$NUM -t jfs2 -e x $VG $LP; crfs -v jfs2 -d /dev/$SAP$NUM -m /oracle/$SID/$SAP$NUM ... (14 Replies)
Discussion started by: arorap
14 Replies

8. Shell Programming and Scripting

CSV File Creation Within Shell Script

Hi All, I am trying to create a CSV file within a shell script test.ksh and the code snippet is something like below: #!/usr/bin/ksh # Set required variables. . $HOME/.prof # Output file path Group1=/tmp/G1.csv Group2=/tmp/G2.csv Group3=/tmp/G3.csv $ORACLE_HOME/bin/sqlplus -s... (2 Replies)
Discussion started by: swasid
2 Replies

9. Shell Programming and Scripting

Script to print file name and its creation date

Hello , I am looking for a script to print file name and its last updated time. FILE CREATION-TIME FILE-NAME 24/10/2017 12:34 TDR-IU-8-2017.10.24.07:40:00-2017.10.24.07:45:00 when we run l command it print the directory and the files with details like permission,... (1 Reply)
Discussion started by: sadique.manzar
1 Replies

10. UNIX for Beginners Questions & Answers

Need UNIX script to check checksum and dummy file creation.

Hi Folks, I need a UNIX script which will copy files(Table wise) from source directory to destination directory (Under table directory) and also creates 2 additional files after getting copied to destination directory with extension .pdy and .ldy , . pdy file will be zero byte file should get... (4 Replies)
Discussion started by: Nicks1412
4 Replies
All times are GMT -4. The time now is 03:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy