Solved

Unix Script

Posted on 2013-10-24
9
363 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 77

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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

803 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