need a shell script to extract the files from source file and check whether those files existonserve


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need a shell script to extract the files from source file and check whether those files existonserve
# 8  
Old 02-22-2012
sample informatio in the make file:
Code:
src/vsxa0142.cxx src/vsxf0229.sc  src/vsxf0323.sc  src/vsxf0865.sc
#       src/vsxa0168.cxx src/vsxf0231.sc  src/vsxf0324.sc  src/vsxf0866.sc
#       src/vsxa0176.cxx src/vsxf0232.sc  src/vsxf0325.sc  src/vsxf0867.sc
#       src/vsxa0180.cxx src/vsxf0233.sc  src/vsxf0332.sc  src/vsxf0868.sc
#       src/vsxa0221.cxx src/vsxf0234.sc  src/vsxf0362.sc  src/vsxf0932.sc
#       src/vsxg0001.cxx src/vsxf0264.sc  src/vsxf0364.sc  src/inbuf.C
#       src/vsxg0004.cxx src/vsxf0265.sc  src/vsxf0368.sc  src/outbuf.C
#       src/vsxg0005.cxx src/vsxf0266.sc  src/vsxf0369.sc  src/printbuf.C
 src/vsxs0016.C   src/vsxa0172.cxx src/vsxg0153.cxx src/vsxa0076.cxx

thanks for the reply.this is the information in the make file.ultimate goal is all the files names which are having .c|cxx|h etc in the make file should also present in the server.if not present need to get that file names from the external vendors.Problem is there are thousands of files with extensions.need to search the files in server and if they present in server ok or else need to note down the file names which are missing.
hope i have provided requested details

Last edited by Franklin52; 02-22-2012 at 06:01 AM.. Reason: Code tags
# 9  
Old 02-22-2012
awk

Hi Murali,

Try this one,

Code:
#! /usr/bin/bash
makefile="File"
filenotfoundlog="filenotfoundlog.log"
filefoundlog="filefoundlog.log"
for files in `awk '$0 !~ /^#/{split($0,a," ");for(i=1;i<=NF;i++){if ( a[i] ~ /\.(c|cxx|h|hxx|sc)$/ ){print a[i];}}}' $makefile`
do
        if [ -f "$files" ]; then
                echo "$files" >>$filefoundlog
        else
                echo "$files" >>$filenotfoundlog
        fi
done

Just assign makefile name and output logs name based on you wish.
This script will give two log file.
1. what are the file not found in the system - filenotfoundlog.
2. what are the files found in the system - filefoundlog.

I have some assumtion,
1. make file is space separated file and have the full path in make file.

Code:
src/vsxs0016.C src/vsxa0172.cxx src/vsxg0153.cxx src/vsxa0076.cxx

In the above line, i assume that
Code:
src

is a base name of that file.

Cheers,
RangaSmilie
# 10  
Old 02-22-2012
Hi thanks a lot for the reply.I guess it is giving trouble at awk part.After execution of the script it throwing an error.
Error :
awk: can't open File
#
# 11  
Old 02-22-2012
awk

Quote:
Originally Posted by muraliinfy04
Hi thanks a lot for the reply.I guess it is giving trouble at awk part.After execution of the script it throwing an error.
Error :
awk: can't open File
#
Just change the makefile name that is your input file right ?

Code:
makefile="File"

Cheers,
RangaSmilie
This User Gave Thanks to rangarasan For This Post:
# 12  
Old 02-22-2012
Superb.Thanks for the reply.It is working ..cheers
# 13  
Old 02-22-2012
awk

wc!!! Cheers Smilie
# 14  
Old 02-22-2012
r u working in chennai?may i know where are u working?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to check a file and delete old files

Hello, I needed help with a shell script where in it checks if a file exists under a directory and also checks the age of the file and delete it if it is older than 3 weeks. thanks (10 Replies)
Discussion started by: hasn318
10 Replies

2. Shell Programming and Scripting

Shell/perl script to check for files

Hi, I am trying to write a script for following scenario: I have a list of countries from where I receive files...eg. (Indonesia, Thailand, Australia...etc) For each country, I have a list of files that they send. IND -- a,b,c TH -- p,q,r AU -- x,y,z The path for these files could... (2 Replies)
Discussion started by: neil.k
2 Replies

3. Shell Programming and Scripting

Standardization of input source data files using shell script

Hi there, I'm a newbie in unix and am fishing for options related to how raw input data files are handled. The scenario, as I'm sure y'all must be very familiar with, is this : we receive upwards of 50 data files in ASCII format from various source systems - now each file has its own structure... (3 Replies)
Discussion started by: Prat Khos
3 Replies

4. Shell Programming and Scripting

How to check whether directory has files in it or not in shell script?

hi, I am having script in which i want to check if directory has any file in it or not. If directory contains a single or more files then and only then it should proceed to further operations... P.S.: Directory might have thousand number of files. so there might be chance of getting error... (4 Replies)
Discussion started by: VSom007
4 Replies

5. Shell Programming and Scripting

Shell script to check files if exist else touch the file

Hi All, Thanks in Advance I wrote the following code if then echo "version is 1.1" for i in "subscriber promplan mapping dedicatedaccount faflistSub faflistAcc accumulator pam_account" do FILE="SDP_DUMP_$i.csv" echo "$FILE" ... (5 Replies)
Discussion started by: aealexanderraj
5 Replies

6. Shell Programming and Scripting

shell script to take input from a text file and perform check on each servers and copy files

HI all, I want to script where all the server names will be in a text file like server1 server2 server3 . and the script should take servernames from a text file and perform copy of files if the files are not present on those servers.after which it should take next servername till the end of... (0 Replies)
Discussion started by: joseph.dmello
0 Replies

7. Shell Programming and Scripting

perl script to check if empty files are created and delete them and run a shell script

I have a local linux machine in which the files are dumped by a remote ubuntu server. If the process in remote server has any problem then empty files are created in local machine. Is there any way using perl script to check if the empty files are being created and delete them and then run a shell... (2 Replies)
Discussion started by: hussa1n
2 Replies

8. Shell Programming and Scripting

Shell script to check the files hourly and purge

I'm new to shell scripting... i have been given a task.. can any one help in this regard.... 1) Check hourly for files in <destination-path><destination-file-template><destination-file-suffix> for files older than <destination-file-retention> days and purge. It should then check... (1 Reply)
Discussion started by: satishpabba
1 Replies

9. Shell Programming and Scripting

HOW TO CHECK ONLY .C FILES EXISTS OR NOT IN A FOLDER using IF in C shell script?

Hi friends.. I hav a problem.... I dont know how to check .c files exists r not in a folder using IF in C shell script actually i tried like this if(=~ *.c) even though some .c files or there in the current folder..it is not entering int o the if control statement...... (17 Replies)
Discussion started by: p.hemadrireddy
17 Replies

10. Shell Programming and Scripting

Shell script to transfer the files from source to target server.

I need to write a shell script to transfer the files every hour from source - target server. The cron job should be running every hour and shouldn't copy already copied files to the remote server ? I was able to write intial script but not able to get the logic for (in the next run it should... (12 Replies)
Discussion started by: radhirk
12 Replies
Login or Register to Ask a Question