listing file date and time without usage of pipe


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting listing file date and time without usage of pipe
# 1  
Old 11-28-2011
listing file date and time without usage of pipe

Hi ,
I am using below code to list the 6th,7th and 8th field of the file

Code:
ls -lrt test | awk '{print $6,$7,$8}'

output:
Code:
Nov 21 19:34

Now the problem here is that I want to do it without the usage of pipes as its now allowed in my production environment

Please let me know how it can be achieved

Regards,
Harish
# 2  
Old 11-28-2011
Why is a pipe not allowed in a production environment?
# 3  
Old 11-28-2011
Actually its not allowed in production environment as we need to run through query id
Through backgroud id we can but we have to run it only through query id

So I am looking for an alternative to pipe

Regards,
Harish
# 4  
Old 11-28-2011
I don't understand the meaning of "run through query id", but if you have the stat program (usually you have it by default on Linux), you can display the file modification time with a single command.
# 5  
Old 11-28-2011
Very odd request!
See if this will help...
Code:
stat -c %y test

Code:
awk -v arg="$(ls -l test)" 'BEGIN{split(arg,a);print a[6],a[7],a[8]}'

--ahamed
# 6  
Old 11-28-2011
Bug

Code:
awk '{print $6,$7,$8}' <(ls -lrt test)

# 7  
Old 11-28-2011
Quote:
Originally Posted by MR.bean
Code:
awk '{print $6,$7,$8}' <(ls -lrt test)

Smilie
Nice!

--ahamed
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Need help with listing file name and modified date on a huge directory

hi, We have a huge directory that ha 5.1 Million files in it. We are trying to get the file name and modified timestamp of the most recent 3 years from this huge directory for a migration project. However, the ls command (background process) to list the file names and timestamp is running for... (2 Replies)
Discussion started by: subbu
2 Replies

2. Red Hat

CPU Usage statistics Dump in a text file over a period of time

I am facing issue related to performance of one customized application running on RHEL 5.9. The application stalls for some unknown reason that I need to track. For that I require some tool or shell scripts that can monitor the CPU usage statistics (what we get in TOP or in more detail by other... (6 Replies)
Discussion started by: Anjan Ganguly
6 Replies

3. AIX

Getting files through find command and listing file modification time upto seconds

I have to list the files of particular directory using file filter like find -name abc* something and if multiple file exist I also want time of each file up to seconds. Currently we are getting time up to minutes in AIX is there any way I can get file last modification time up to seconds. (4 Replies)
Discussion started by: Nitesh sahu
4 Replies

4. UNIX for Dummies Questions & Answers

Memory usage per user,percent usage,sytem time in ksh

Let's say i have 20 users logged on Server. How can I know how much memory percent used each of them is using with system time in each user? (2 Replies)
Discussion started by: roy1912
2 Replies

5. UNIX for Dummies Questions & Answers

add new 'date field' in a pipe delimited file

i need to add a new field in a pipe delimited line. the field will be the current date today. aa|a|s|w|1 as|oiy|oiy|oiy|2 given that all lines are uniformed in the number of fields i want it to look like this:\ aa|a|s|w|1|20120126 as|oiy|oiy|oiy|2|20120126 please help :) (3 Replies)
Discussion started by: kokoro
3 Replies

6. Shell Programming and Scripting

pipe to file named with date

I would like to pipe (redirect ? - what is the right term?) the output of my script to a file named with the current date. If I run this at a command prompt: date +'%Y%m%d" ...it returns "20110429" OK, that's good... so I try: ./script.sh > "'date +%Y%m%d'.csv" I get a file... (1 Reply)
Discussion started by: landog
1 Replies

7. UNIX for Dummies Questions & Answers

Listing file name and date

Hello. I want to make an unix script which create a file with the name and the date of creation of the different files that there are in a directory. Can do you please help me? Thank you in advance. (3 Replies)
Discussion started by: Jfka
3 Replies

8. Solaris

Listing processes with swap usage

Is there any way to get list of processes which are taking maximum swap , my system is showing no swap space in /var/adm/messages and i 'm unable to pin down the process which is consuming max swap space. (11 Replies)
Discussion started by: fugitive
11 Replies

9. Shell Programming and Scripting

Processing a log file based on date/time input and the date/time on the log file

Hi, I'm trying to accomplish the following and would like some suggestions or possible bash script examples that may work I have a directory that has a list of log files that's periodically dumped from a script that is crontab that are rotated 4 generations. There will be a time stamp that is... (4 Replies)
Discussion started by: primp
4 Replies

10. Shell Programming and Scripting

Listing the creation date/time of a file in unix

Hi, I need the unix command which returns only the file name and its creation date/time in unix. I tried ls -l <filename>. But that is giving other details also which I do not want. Could anyone help me out? Thanks. (6 Replies)
Discussion started by: unipepper
6 Replies
Login or Register to Ask a Question