LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-18-2003, 03:37 PM   #1
eastj1974
Member
 
Registered: Feb 2003
Location: Los Angeles
Distribution: Red Hat 8.0
Posts: 68

Rep: Reputation: 15
ls command question


I'm writing a scripts that requires the names and dates of files within a directory.

I could do ls -l to get this information but it also has the owner and rights that I don't need. I thought I could pipe the ls command with a cut command to only get the date and the filename but I can't get it to work.

Does anyone have any suggestions? Thanks.
 
Old 11-18-2003, 04:03 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Have a closer look at awk ...

Cut, btw, should be just fine... what's the problem?


Cheers,
Tink
 
Old 11-18-2003, 05:00 PM   #3
eastj1974
Member
 
Registered: Feb 2003
Location: Los Angeles
Distribution: Red Hat 8.0
Posts: 68

Original Poster
Rep: Reputation: 15
I don't know how to use cut. I assume its in the form

ls -l | cut.

but I don't know what options I need to pass to get the last two columns.
 
Old 11-18-2003, 05:22 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Heh ... have you tried a
man cut? :)


But really, since cut's delimiter handling is
a bit unwieldy I'd suggest using awk ...

try
ls -l | awk '{printf "%2d %3s %s\n", $7, $6, $9}'

Cheers,
Tink
 
Old 11-18-2003, 05:44 PM   #5
eastj1974
Member
 
Registered: Feb 2003
Location: Los Angeles
Distribution: Red Hat 8.0
Posts: 68

Original Poster
Rep: Reputation: 15
thanks that makes worked. I tried using cut with the ' ' delimiter but it wasn't working well. awk is easier. J
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Question About a Command? carlosinfl Linux - General 4 10-28-2005 12:51 PM
Command question satimis Linux - Newbie 2 11-24-2004 08:59 AM
Command question satimis Linux - General 8 06-23-2004 02:43 AM
cp command question satimis Linux - Newbie 1 09-13-2003 08:31 PM
Command Question gauge73 Linux - Newbie 2 02-13-2003 08:18 PM


All times are GMT -5. The time now is 09:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration