Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Unix Script

Posted on 2013-10-24
9
Medium Priority
?
375 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 85

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 80

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 85

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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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 27

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
The viewer will learn how to dynamically set the form action using jQuery.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses
Course of the Month12 days, 2 hours left to enroll

916 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