want to delete timestamp from todays file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting want to delete timestamp from todays file
# 1  
Old 11-07-2003
want to delete timestamp from todays file

i want to delete the time stamp from the file which have a date of yester day
640878 Nov 6 09:08 fbres.01.20031106:09:08:30
here is what my ls -lt command shows in current directory
it want it to be

640878 Nov 6 09:08 fbres.01.20031106
thanks
# 2  
Old 11-07-2003
Re: want to delete timestamp from todays file

Quote:
Originally posted by maverick
i want to delete the time stamp from the file which have a date of yester day
640878 Nov 6 09:08 fbres.01.20031106:09:08:30
here is what my ls -lt command shows in current directory
it want it to be

640878 Nov 6 09:08 fbres.01.20031106
thanks
Im not exactly sure what your intentions are here. Do you want to rename an existing file? Modify the filename in a script? Modify a bunch of files that look like this? Can you elaborate a bit more?

To change the file name, use the mv command

mv $PWD/fbres.01.20031106:09:08:30 $PWD/fbres.01.20031106
where $PWD equals the value of the present working directory (i.e. where your file resides)
# 3  
Old 11-07-2003
google i think i was not clear it is not a single file that arrives

-rw-r--r-- 1 comprod commercial 2417281 Nov 6 09:15 fbdemo.01.20031106:09:15:49
-rw-r--r-- 1 comprod commercial 51873 Nov 6 09:11 fbappr.01.20031106:09:11:30
-rw-r--r-- 1 comprod commercial 0 Nov 6 09:10 fbdoe.01.20031106:09:10:40
-rw-r--r-- 1 comprod commercial 55674 Nov 6 09:10 fbcom.01.20031106:09:10:02
-rw-r--r-- 1 comprod commercial 0 Nov 6 09:09 fbcan.01.20031106:09:09:23
-rw-r--r-- 1 comprod commercial 52767 Nov 6 09:08 fbbur.01.20031106:09:08:46
-rw-r--r-- 1 comprod commercial 640878 Nov 6 09:08 fbres.01.20031106:09:08:30
-rw-r--r-- 1 comprod commercial 20431 Nov 6 09:08 fbab.01.20031106:09:08:14
-rw-r--r-- 1 comprod commercial 160386 Nov 6 09:08 fbcntl.01.20031106:09:08:11
-rw-r----- 1 comprod commercial 3910752 Oct 28 02:59 pgrep.01.20031028:02:59:56

this is my actual entry for today in pwd
i want all the files to be stripped of their time stamp and be moved to some other directory
here is desired out come

-rw-r----- 1 comprod commercial 2417281 Nov 7 05:31 fbdemo.01.20031106
-rw-r----- 1 comprod commercial 51873 Nov 7 05:31 fbappr.01.20031106
-rw-r----- 1 comprod commercial 0 Nov 7 05:30 fbdoe.01.20031106
-rw-r----- 1 comprod commercial 55674 Nov 7 05:29 fbcom.01.20031106
-rw-r----- 1 comprod commercial 0 Nov 7 05:28 fbcan.01.20031106
-rw-r----- 1 comprod commercial 52767 Nov 7 05:28 fbbur.01.20031106
-rw-r----- 1 comprod commercial 640878 Nov 7 05:27 fbres.01.20031106
-rw-r----- 1 comprod commercial 20431 Nov 7 05:27 fbab.01.20031106
-rw-r----- 1 comprod commercial 160386 Nov 7 05:23 fbcntl.01.20031106

:-) thanks in advance
# 4  
Old 11-07-2003
Check the search function. Here is one thread that I think may solve your problem Code To Rename Multiple Dirs This thread is about renaming hundreds of directories but you could modify the script that was posted for use on regular files. FYI - I used the keyword 'rename' in my search.

Try this....

#!/bin/ksh

LIST=$(ls -1 $PWD) #Note: Assumption is all are files; no dirs and that all files in PWD are to be renamed. (Add your own rules here!)

for i in $LIST
do
mv $i ${i%%:*}
done

echo "Complete"

Last edited by google; 11-07-2003 at 07:29 AM..
# 5  
Old 11-07-2003
google iam sure this is a very effective solution but what i want is some command and not a shell script something using pipes
which i can run in any directory without bothering to change the
value of $pwd each time i run the script .iam unable to do the same \
thanks for the prompt reply :-)
# 6  
Old 11-07-2003
Ok, you will then need to explore using the find command. Find can recursively search all directories from the starting dir that you provide it. It can also perform some action on the files that it finds - you of course define the action to be taken. Take a look at the link in my previous post as it has examples using the find command. Also, see man find
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to delete filesappended with timestamp?

I have the following script #!/bin/bash # Script for running the snapshot of target directories now=$(date +'%Y-%m-%d') /bin/hdfs dfs -createSnapshot /apps/hive/warehouse/xyz.db $now How do i delete the same in a script see below a example ... (1 Reply)
Discussion started by: tspk99
1 Replies

2. UNIX for Beginners Questions & Answers

How to list todays file in perticular folder?

How to list todays file in perticular folder Moved thread to appropriate forum (9 Replies)
Discussion started by: pspriyanka
9 Replies

3. Shell Programming and Scripting

Script to keep todays files based on Timestamp

Hi i need to keep todays files based on timestamp and archive the remaining files ex: Managerial_Country_PRD_20150907.csv Managerial_Country_PRD_20150907.csv Managerial_Country_PRD_20150906.csv Managerial_Country_PRD_20150905.csv (6 Replies)
Discussion started by: ram1228
6 Replies

4. UNIX for Dummies Questions & Answers

Script to keep todays files based on Timestamp

Hi i need to keep todays files based on timestamp and archive the remaining files ex: Managerial_Country_PRD_20150907.csv Managerial_Country_PRD_20150906.csv Managerial_Country_PRD_20150905.csv (2 Replies)
Discussion started by: ram1228
2 Replies

5. Shell Programming and Scripting

how to get todays file name

Hi ! there can you please tell me how to get full files having today date like if i have files like this(below) , i want to grep only sra + today's date + what ever thing is there after date . grep `sra*$date*.csv` >>> i tried this one but its not working . sra28-08-2011xyz.csv... (1 Reply)
Discussion started by: sravan008
1 Replies

6. UNIX for Dummies Questions & Answers

How to compare a file by its timestamp and store in a different location whenever timestamp changes?

Hi All, I am new to unix programming. I am trying for a requirement and the requirement goes like this..... I have a test folder. Which tracks log files. After certain time, the log file is getting overwritten by another file (randomly as the time interval is not periodic). I need to preserve... (2 Replies)
Discussion started by: mailsara
2 Replies

7. Shell Programming and Scripting

Getting a relative timestamp from timestamp stored in a file

Hi, I've a file in the following format 1999-APR-8 17:31:06 1500 3 45 1999-APR-8 17:31:15 1500 3 45 1999-APR-8 17:31:25 1500 3 45 1999-APR-8 17:31:30 1500 3 45 1999-APR-8 17:31:55 1500 3 45 1999-APR-8 17:32:06 1500 3 ... (1 Reply)
Discussion started by: vaibhavkorde
1 Replies

8. Shell Programming and Scripting

Delete log file entries based on the Date/Timestamp within log file

If a log file is in the following format 28-Jul-10 ::: Log message 28-Jul-10 ::: Log message 29-Jul-10 ::: Log message 30-Jul-10 ::: Log message 31-Jul-10 ::: Log message 31-Jul-10 ::: Log message 1-Aug-10 ::: Log message 1-Aug-10 ::: Log message 2-Aug-10 ::: Log message 2-Aug-10 :::... (3 Replies)
Discussion started by: vikram3.r
3 Replies

9. Shell Programming and Scripting

How to grep a string in todays file

Hello guys - I am new to Unix. I am trying to understand how to grep a perticular string in todays file? I am trying this syntax but not getting what I am looking for: % grep `date '+%d/%b/%Y'` For instance there are 2 files generated today with same data. I am trying to find them and... (21 Replies)
Discussion started by: DallasT
21 Replies

10. Shell Programming and Scripting

How to list todays file

Hi Friends, How to list todays file from a directory listing of files for amny dates. I tried with the following options but not working : find . -name "esi01v*" -mtime 1 -ls find . -name "esi01v*" -ctime 1 -ls find . -name "esi01v*" -mtime 1 Please advise (19 Replies)
Discussion started by: unx100
19 Replies
Login or Register to Ask a Question