Get file name which include the current date


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Get file name which include the current date
# 8  
Old 11-06-2012
Quote:
Originally Posted by RudiC
This seems like there's a <carriage return> character in N, as it prints A20121105, returns to char #1, and prints 01.DC. Try echo $N|od -tx1 and publish the result here.
That did not work. Just got a bunch of numbers as output.
# 9  
Old 11-06-2012
That's exactly what I'm out for! The numbers represent the characters in your string, ALL chars, including invisible control chars.
# 10  
Old 11-06-2012
Using
Code:
echo $N|od -tx1

(if using code similar to the first one I posted) does not work. However using
Code:
echo $N2|od -tx1

gives the following output

0000000 41 32 30 32 30 31 32 31 31 30 36 0d 0d 30 31 2e
0000020 44 43 0d 0a
0000024
# 11  
Old 11-06-2012
Try like..
Code:
 ls -ltr |echo  A`date '+%Y%m%d'`01.txt

# 12  
Old 11-06-2012
Quote:
Originally Posted by Immelstorn
. . .
Code:
0000000 41 32 30 32 30 31 32 31 31 30 36 0d 0d 30 31 2e
0000020 44 43 0d 0a                       ^--^--- see that?
0000024        ^--- and that?

You've got (multiple!) <CR> chars in your string variable, wherever they may come from. You need to check the development of that variable (and its "parent" variables) from the first assignment to eliminate those. Then your printout will be OK.
# 13  
Old 11-06-2012
Yes, I just realized that two. Seems that creating the scripts in Windows and then export them to the Unix environment is not the best idea.

Created the script in emacs and the <CR> chars disappeared.

Thanks for all the help.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Replace date in file every day with current date

I Have text like XXX_20190908.csv.gz need to replace Only date in this format with current date every day Thanks! (1 Reply)
Discussion started by: yamasani1991
1 Replies

2. UNIX for Beginners Questions & Answers

“sed” replace date in text file with current date

We want to call a parameter file (.txt) where my application read dynamic values when the job is triggered, one of such values are below: abc.txt ------------------ Code: line1 line2 line3 $$EDWS_DATE_INSERT=08-27-2019 line4 $$EDWS_PREV_DATE_INSERT=08-26-2019 I am trying to write a... (3 Replies)
Discussion started by: pradeepp
3 Replies

3. Shell Programming and Scripting

Subtract a file's modification date with current date

SunOS -s 5.10 Generic_147440-04 sun4u sparc SUNW,SPARC-Enterprise Hi, In a folder, there are files. I have a script which reads the current date and subtract the modification date of each file. How do I achieve this? Regards, Joe (2 Replies)
Discussion started by: roshanbi
2 Replies

4. Shell Programming and Scripting

Find big file include current date

Hi, I want to put script. The script is to show file that larger than 100MB include current date (eg: today date). After find the date, it will compress list file and split the tar.gz file. Any idea how to do that? This bash script will run auto everyday. It's will transfer will to other... (12 Replies)
Discussion started by: mzainal
12 Replies

5. UNIX for Dummies Questions & Answers

Delete a row from a file if one column containing a date is greater than the current system date

Hello gurus, I am hoping someone can help me with the required code/script to make this work. I have the following file with records starting at line 4: NETW~US60~000000000013220694~002~~IT~USD~2.24~20110201~99991231~01~01~20101104~... (4 Replies)
Discussion started by: chumsky
4 Replies

6. HP-UX

How do I include header files outside of my current directory

I am trying to compile a file called PPFormatageMUT.c in which I have included header file which are at some other location but the point is that while compiling the file, it is throwing error saying that error : no such file or directory source code location:... (1 Reply)
Discussion started by: ezee
1 Replies

7. Shell Programming and Scripting

Help setting PS1 prompt to include current time

Hi, I'm using the ksh shell and I'd like to set my PS1 prompt on an AIX system to include, amongst ther things, the current time. This was my best effort: export PS1=$(date -u +%R)'${ME}:${PWD}# ' but this only sets the time to the value when PS1 is defined and the time value doesn't... (4 Replies)
Discussion started by: m223464
4 Replies

8. Shell Programming and Scripting

Perl: Extracting date from file name and comparing with current date

I need to extract the date part from the file name (20080221 in this ex) and compare it with the current date and delete it, if it is a past date. $file = exp_ABCD4_T-2584780_upto_20080221.dmp.Z really appreciate any help. thanks mkneni (4 Replies)
Discussion started by: MKNENI
4 Replies

9. Shell Programming and Scripting

File date vs Current date

I am a newbie in shell scripting, hope you can advice how can I compare the date/time of file extracted from 'll' and current system date/time. I have done the following: ll -rt > $FILE_AGE_LOG FILE_DATETIME=`more $FILE_AGE_LOG | head -02 | cut -c 45-57` It returns 'May 4 19:11'. If I... (4 Replies)
Discussion started by: trexlim
4 Replies

10. UNIX for Dummies Questions & Answers

how to give current date in file name?

:) I want to rename a file by giving the actual date as a file name. Is there a command for this? For example file is this: a.txt I want to copy it with a command like this: a20050510.txt (3 Replies)
Discussion started by: simurg11
3 Replies
Login or Register to Ask a Question