Modified dates to a file without the cut command


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Modified dates to a file without the cut command
# 1  
Old 12-04-2001
Modified dates to a file without the cut command

how can i write the modified dates of all of the files in my directory to a file. i dont want any of the other junk from ls in there. i cant use the cut command
# 2  
Old 12-04-2001
Why can't you use cut? And do you want the filename with the date of last modification?

Smilie
# 3  
Old 12-05-2001
Hi Cypher,
You can use this:

ls -sl | awk '{print $9,$10} > file.out

to accomplish what you want. You may have to adjust $9 and $10 depending on your system output. I ran this on Solaris 8. IF you have never used awk, the above statment will essentially copy columns 9 and 10 of the ls -sl output info the log file and nothing else. In my case, column 9 is the time and 10 is the filename. If you don't want the filename, simply remove the ",$10" from above. Also, you could change the ls command from ls -sl to ls -c if you wanted to learn when the file permissions, ownership, etc were last changed. You may have to change 9 and 10 again to compensate for your system output.
# 4  
Old 12-05-2001
Re: Modified dates to a file without the cut command

hi,guey.
you could try like this:

touch <filename>Smilie
# 5  
Old 12-05-2001
Lots o' choices!

Heres another:
(ls -la|while read a b c d e f; do echo $e; done) > myfile

or another, if you want only files (not directories):

find . -type f -exec ls -l {} \; | awk '{print $5}' > myfile
(This is how I personally would do it...)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Cut command: can't make it cut fields

I'm a complete beginner in UNIX (and not a computer science student either), just undergoing a tutoring course. Trying to replicate the instructions on my own I directed output of the ls listing command (lists all files of my home directory ) to My_dir.tsv file (see the screenshot) to make use of... (9 Replies)
Discussion started by: scrutinizerix
9 Replies

2. UNIX for Dummies Questions & Answers

How to write the dates between 2 dates into a file

Hi All, I am trying to print the dates that falls between 2 date variables into a file. Here is the example. $BUS_DATE =20120616 $SUB_DATE=20120613 Output to file abc.txt should be : 20120613,20120614,120120615,20120616 Can you pls help me accomplish this in LINUX. Thanks... (5 Replies)
Discussion started by: dsfreddie
5 Replies

3. Shell Programming and Scripting

command to know last modified user of a file

Hi I have below requirement. There are set of files to be monitored for audit purpose. Source file contains the file name and its location on server. Need to have shell script which generate a output file which is having the details of above files ( last modified user name ,lat update... (12 Replies)
Discussion started by: karnatis
12 Replies

4. Shell Programming and Scripting

Cut Command error cut: Bad range

Hi Can anyone what I am doing wrong while using cut command. for f in *.log do logfilename=$f Log "Log file Name: $logfilename" logfile1=`basename $logfilename .log` flength=${#logfile1} Log "file length $flength" from_length=$(($flength - 15)) Log "from... (2 Replies)
Discussion started by: dgmm
2 Replies

5. Shell Programming and Scripting

Comparing the modified dates of files in two directories

Hi Is it possible to compare the modified dates of all the files in two directories using shell script? I would like to take a backup of a directory in production server regularly. Instead of copying all the files in the directory, is it possible to list only the files that are... (2 Replies)
Discussion started by: ashok.k
2 Replies

6. Shell Programming and Scripting

Using cut command in a fixed length file

Hi, I have a file which have set of rows and has to create separate files based on the id. Eg: 001_AHaris020 001_ATony030 002_AChris090 002_ASmit060 003_AJhon001 Output: I want three files like 001_A.txt, 002_A.txt and 003_A.txt. 001_A.txt should have ... (4 Replies)
Discussion started by: techmoris
4 Replies

7. Shell Programming and Scripting

File processing is very slow with cut command

Dear All, I am using the following script to find and replace the date format in a file. The field18 in the file has the following format: "01/26/2010 11:55:14 GMT+04:00" which I want to convert into the following format "20100126115514" for this purpose I am using the following lines of codes:... (5 Replies)
Discussion started by: bilalghazi
5 Replies

8. UNIX for Dummies Questions & Answers

how to retrieve original contents of a modified file (modified using vi)

Made changes to a file using vi editor and saved those changes now realised that the changes are not required How can I get the previous version of the file.i.e the one which was there on which I had made changes (3 Replies)
Discussion started by: novice100
3 Replies

9. UNIX for Dummies Questions & Answers

list exe files modified before certain dates

Can you please tell me how I can list all EXE files in a dir and Subdir which where modified say before 01/01/2006 (2 Replies)
Discussion started by: fremont
2 Replies

10. Shell Programming and Scripting

Comparing last modified dates

Hi All. Can someone please give me an example of how I'd do a comparison to find out if the last modified date of a file is newer than yesterday (i.e. today - 1 day)? Example: if ; then echo "Do something..." fi Any ideas or examples? Thanks. (1 Reply)
Discussion started by: dmilks
1 Replies
Login or Register to Ask a Question