Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Unix Script

Posted on 2013-10-24
9
Medium Priority
?
370 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 79

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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:David
ID: 39602193
What, exactly is the question you are asking?
0
 
LVL 26

Accepted Solution

by:
wilcoxon earned 2000 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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Fine Tune your automatic Updates for Ubuntu / Debian
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

715 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