Please show us your complete script as it currently stands.
It looks like you have confused ftp into thinking that a vertical bar character (|) should be used as a filename instead of as a separator in a shell pipeline.
Whoooops! I think there is a mistake in my suggestion. The expression to match the filenames should be wrapped in double quotes, " and somehow I've lost the beginning out. Try this amended version with the addition in red:-
Apologies,
Robin
Whoooops! I think there is a mistake in my suggestion. The expression to match the filenames should be wrapped in double quotes, " and somehow I've lost the beginning out. Try this amended version with the addition in red:-
Apologies,
Robin
Robin,
I think you need to loose the double-quote to allow shell to do name expansion.
Hi Robbin,
vgersh99 is correct in noting that quoted asterisks, question marks, etc. are matched by the shell as literal strings. To use asterisks to match any string of characters in a pathname and to use a question mark to match any single character in a pathname in pathname pattern expansions, the asterisks and question marks cannot be quoted.
Since there are no IFS characters in either Deposit_ or Withdrawal_, no quotes are required. But, any of the following would work:
unless the pathnames roll over from Deposit_999 to Deposit_1000 and Withdrawal_999 to Withdrawal_1000.
Hi fretagi,
If you are trying to find the last two files based on most recent modification timestamp instead of by alphanumeric filename sort order consider trying one of the following instead:
Either of these will work even when the number of digits increases in the matched filenames.
I tried the code outside the script just like this:
and
It should not pick the .checksum extension files only the .csv files.
So filter for csv files:
and personally I'm in favour of using head over tail (imagine your directory has 300 files in it ...)
Quote:
Hi
Now using the code suggested by a forum member:
It gives me the following results:
Your version of /bin/sh does not recognise the more modern process substitution syntax:
You could either modify the "shebang" line at the top of your script to use ksh if you have it, or bash, or alternatively use the older process substitution syntax using backticks:
Andrew
These 2 Users Gave Thanks to apmcd47 For This Post:
Replacing D_file=$(ls -1 *Deposit_* | tail -1) with D_file=`ls -1 *Deposit_* | tail -1` worked fine
---------- Post updated at 11:59 AM ---------- Previous update was at 11:32 AM ----------
there is a need to also include the Deposit_699.checksum and Withdrawal_700.checksum. I did include in the script like this:
but this did not work out..
Hi
I have a scenario:
I have a directory say DIR1 (no sub directories) and have few files in that directory as given below:
app-cnd-imp-20150820.txt
app-cxyzm-imp-20150820.txt
app-petco-imp-20150820.txt
app-mobility-imp-20150820.txt
app-mobility-imp-20150821.txt... (7 Replies)
Hi Friends,
Newbie to shell scripting
Currently i have used the below to sort data based on filenames and datestamp
$ printf '%s\n' *.dat* | sort -t. -k3,4
filename_1.dat.20120430.Z
filename_2.dat.20120430.Z
filename_3.dat.20120430.Z
filename_1.dat.20120501.Z
filename_2.dat.20120501.Z... (12 Replies)
Hi Friends,
Newbie to shell scripting. Currently i have used the below to sort data based on filenames and datestamp
$ printf '%s\n' *.dat* | sort -t. -k3,4
filename_1.dat.20120430.Z
filename_2.dat.20120430.Z
filename_3.dat.20120430.Z
filename_1.dat.20120501.Z
filename_2.dat.20120501.Z... (1 Reply)
Hi All,
I am trying to rsync some of the latest files from remote m/c to my local linux box.
Folder structure in my remote m/c looks like this
/pub/Nightly/Package/ROLL/WIN
/pub/Nightly/Package/SOLL/sol
/pub/Nightly/Package/SOLL/linux
Each of the folder contains gzip files which on daily... (0 Replies)
What commands do you need to transfer a specfic portion of a file content to another file?
eg file_one has
00012 10012
00013 10013
00014 10014
So I just want to transfer all the values of the second column ie 10012, 10013, 10014 to be transferred to file_two?
Thanks in advance.... (1 Reply)
Im trying to transfers a file from one unix server to another , make some changes and then send it back to the original server. All this using modems.
I've been using "cu" and i can "get" the file but i can't "put" it. Besides I need to do this using a shell script. I can write a script to get... (4 Replies)