I am writing a script that looks for files. I need to know if there is a placeholder character when doing this. I know that you can user a wildcard (*) character, but I would prefer to be a bit more specific. When I get files in a specific directory, I know part of the name, but not the rest and I'm interested in determining if a file was placed there today. The naming convention for the files are:
INCOME-ccyymmdd-hhiissT.zip
where:
cc is the century
yy is the year
mm is the month
dd is the day
hh is the hour
ii is the minute
ss is the second
The problem is that I can figure out the day, but I have no earthly idea what the time will be! As and example, I could get a file that is named:
INCOME-20020819-142030T.zip
This would be a file that was sent on 8/19/2002 at 2:20:30 pm. What I have in my script is:
What I would like to know is if there is a placeholder so I could make the if statement something like:
if [ -f /export/home/INCOME-20020819-$$$$$$T.zip ]
where the $$$$$$ represents the time (just a placeholder, not a wildcard).
if [ -f /export/home/INCOME-20020819-*T.zip ] works and I found out before I got any replies. I also need the ? placeholder for other things (since this one won't require it, thanks!). One more question. Now that I can tell there's a file there (since the logic said it found the file), how can I determine the real name of the file (the wildcard lets me know there's a match, but doesn't tell me exactly what the name is of the file it found (should never be but one match))? Please advise.
You can just use that pattern where ever you need the name. If you want to store the name in a variable, you could do:
variable=`echo /export/home/INCOME-20020819-$$$$$$T.zip`
It almost looks like it duplicated 15531 three times. What I am specifically looking to do is the get the actual name of the file (INCOME-20020819-172152T.zip) so I can unzip it then ftp it somewhere. I know how to do the unzipping and ftping, just don't know how to get the actual name of the file. Please help!
As part of a bash the below line strips off a numerical prefix from directory 1 to search for in directory 2.
for file in /home/cmccabe/Desktop/comparison/missing/*.txt
do
file1=${file##*/} # Strip off directory
getprefix=${file1%%_*.txt}
... (5 Replies)
Data files coming in different names in a file name called process.txt.
1. shipments_yyyymmdd.gz
2 Order_yyyymmdd.gz
3. Invoice_yyyymmdd.gz
4. globalorder_yyyymmdd.gz
The process needs to discard all the below files and only process two of the 4 file names available
... (1 Reply)
HI Guys,
I have some 8 files with different name and extensions. I need to check if they are present in a specific folder or not and also want that script to show me which all are not present. I can write if condition for each file but from a developer perspective , i feel that is not a good... (3 Replies)
Hi,
I have a files in a directory as below :-
ls -1
mqdepth-S1STC02
proc-mq-S1STC01
proc-mq-S1STC02
proc-mq-S1STC03
Whereever i have S1STC i need to copy them into new file with file name S2STC.
expected output :-
ls -1
mqdepth-S2STC02
proc-mq-S2STC01
proc-mq-S2STC02... (3 Replies)
Hi All,
I am facing a problem while using SED in Linux.
I have a property file which contains a string
local.mds.dir=${basedir}/deployCompositesIt has be to replaced with another string, and value of that string should be initialized at runtime. So I use placeholder there. My substituted... (2 Replies)
Hi,
As a newbie, I'm desperate ro make my shell script work. I'd like a script which checks all the files in a directory, check the file name, if the file name ends with "extracted", store it in a variable, if it has a suffix of ".roi" stores in another variable. I'm going to use these two... (3 Replies)
Hi all,
I'm pretty new to Shell scripting and I need some help to split a source text file into multiple files. The source has a row with pattern where the file needs to be split, and the pattern row also contains the file name of the destination for that specific piece. Here is an example:
... (2 Replies)
Hi,
I have a data file xyz.dat similar to the one given below,
2345|98|809||x|969|0
2345|98|809||y|0|537
2345|97|809||x|544|0
2345|97|809||y|0|651
9685|98|809||x|321|0
9685|98|809||y|0|357
9685|98|709||x|687|0
9685|98|709||y|0|234
2315|98|809||x|564|0
2315|98|809||y|0|537... (2 Replies)
Sun Solaris Unix Question
Haven't been able to find any solution for this situation. Let's just say the file names listed below exist in a directory. I want the find command to find all files in this directory but at the same time I want to eliminate certain file names or files with certain... (2 Replies)
Hi
How can i dynamically read files names from a list file and execute them from a single shell script.
Please help its urgent
Thanks in Advance (4 Replies)