Solved

Unix Script

Posted on 2013-10-24
9
359 Views
Last Modified: 2013-10-26
Hi
i want a unix script which looks for files wix%.csv . if files exist it should create
a file list.txt with file names . If no files exist it should create a dummy file  named wix%.csv and create list.txt with the dummy file name
thanks
0
Comment
Question by:uco
9 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 39599519
Since you say files plural, does that mean you want to look for the file wix%.csv in different directories?  If so, which?
Or did you mean any file matching wix*.csv in the current working directory?
0
 
LVL 76

Expert Comment

by:arnold
ID: 39599592
find / -name "^wix*\.csv" >> list.txt

The creation for the files you have to define where and under what conditions it should create an empty file.
0
 
LVL 84

Expert Comment

by:ozo
ID: 39599619
you can
touch wix%.csv
to create a dummy file
If the file already exists, it is not created, so you can just always do it before you start (unless you need to preserve its modification and access times)
But where would you want to create it?
Under / ?
under all directories?
(it probably wouldn't make much sense to create one under /dev)
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 48

Expert Comment

by:Tintin
ID: 39600033
>If no files exist it should create a dummy file  named wix%.csv and create list.txt with the dummy file name

what should the dummy file name be?
0
 

Author Comment

by:uco
ID: 39600583
thanks for the replies
I am looking for multiple files with names wix*.csv in the same directory (dev)
Empty file need to be created if no files exist with the name wix*.csv, empty to be created int he same directory (dev)

the dummy file name should be starting with 'wix'  could have anything after wix , file extension should be csv

thanks
0
 
LVL 47

Expert Comment

by:dlethe
ID: 39602193
What, exactly is the question you are asking?
0
 
LVL 26

Accepted Solution

by:
wilcoxon earned 500 total points
ID: 39602204
find dev -name wix\*.csv > list.txt
if [ ! -s list.txt ]; then
    touch wixempty.csv
    echo wixempty.csv > list.txt
fi

Open in new window

0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now