03-03-2011
Great to see your progressing, just be carefull of using cut that way as the numbers 44, 38, etc are very dependant on the length of filename and directory pathes. The sed command I posted earlier cuts the date from the end of the string avoiding these issues.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I can use the following command to create a file with some name then underscore and then date appended to it in the format 'DD-MM-YYYY':
touch "newfile_`date '+%d-%m-%Y'`"
But it gives me error when I try with the similar command to create a file with the date format 'DD/MM/YYYY'. I... (4 Replies)
Discussion started by: royalibrahim
4 Replies
2. UNIX for Dummies Questions & Answers
I am trying to find a way to create a script which will extract the first line of a file and then rename the file (or create a new file with the same content as the old file) using the first line as the name. The first line being a single word, that is. I am hopeless at programming, if anyone can... (5 Replies)
Discussion started by: s.plumb
5 Replies
3. UNIX for Dummies Questions & Answers
I am looking to do something where if I created a file named backup,or whatever it would print a name like “backup_Apr_11_2011”. Thanks citizencro (1 Reply)
Discussion started by: citizencro
1 Replies
4. Shell Programming and Scripting
I have lots of files in this format:
dvgrab-2003.06.29_15-30-24.mpg
The numbers represents the date and time (YYYY.MM.DD_HH-MM-SS)
How can I extract the dates from the filenames, and use the dates in the file timestamp?
I guess this can be done by using "find", "sed" and "touch"?
Can... (6 Replies)
Discussion started by: qwerty1234
6 Replies
5. UNIX for Dummies Questions & Answers
Hi,
I have a bash script which outputs a file with current year and month in the filename.
Last line is:
cat result_* > output.$(date +%y%m)
So for Feb 2013 this gives me output.1302
Now I am requested to run the script every first day of the month, but with the previous month in... (4 Replies)
Discussion started by: viscacha
4 Replies
6. UNIX for Dummies Questions & Answers
Hi All,
I have incoming source files abcmmyy.txt I need to extract the mmyy part from the filename and pass that to a variable . I really appreciate your quick response on this.
Thanks
raj (7 Replies)
Discussion started by: rajeevm
7 Replies
7. Shell Programming and Scripting
Hello experts, I want to join a file with files whosE names are mentioned in one of the columns of the same file.
File 1
t1,a,b,file number 1
t1,a,c,file number 1
t2,c,d,file number 2
t2,c,e,file number 2
t2,c,f,file number 2
t2,c,g,file number 2
t3,e,f,file number 3
file number 1... (3 Replies)
Discussion started by: ritakadm
3 Replies
8. UNIX for Beginners Questions & Answers
Hi,
I'm totally new in sell script and working with a shell code. I want to extract the date and time from the filenames. The filenames are different but all of them begins with WI_ SCOPE_:
WI_SCOPE_DATA_CHANGE_2017-09-12_15-30-40.txt
WI_SCOPE_BACK_COMPLETE_QUEUE_2017-09-12_15-31-40.txt... (5 Replies)
Discussion started by: Home
5 Replies
9. UNIX for Beginners Questions & Answers
Hi,
I want to extract part of filename, for eg:
File="010020004_S-TOR-Sort-CASAP_20170519_121504_0007.TXT"
here i need first 5 words of file i.e.
FilePart="$(echo "${File%"${File#******}"}")"
Echo $FilePart
010020004_S-TOR-Sort-CASAP
But what if i get filename like below:
... (3 Replies)
Discussion started by: gnnsprapa
3 Replies
10. UNIX for Beginners Questions & Answers
Hi,
I am facing one scenario in which I need to extract exact position of date and time from the name of the files. For example, Below is the record in which I need to extract position of YYYYMMDD,HHMISS and YYMMDD. Date and time variables can come more than once. I need to use these position... (13 Replies)
Discussion started by: Prathmesh
13 Replies