LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-04-2013, 07:54 PM   #16
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235

Quote:
Originally Posted by grail View Post
And here is a Ruby option:
And I was actually expecting Ruby to be best with it. And as I imagined how it could be done in Awk, with formats like that where we still let the shell produce the file list, it would be possible only that if we are to test if a file is a file, we already have to use the system() function.
 
Old 07-05-2013, 02:08 AM   #17
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Actually I think you could use co-process (here) option with stat to send and retrieve the data in awk.
 
Old 07-07-2013, 03:08 AM   #18
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
I don't think you would have to go as far as using co-processes since you don't have to send data back. Still as implied you would use getline much like how you could do it here.
Code:
cmd = "stat -c '%y' " file
if (cmd | getline timestamp) {
    ...
    close (cmd)
}
Yet that was actually not what I was concerned for. The problem was how you could test if a file is a file from multiple arguments. And directories are very irregular with their timestamp.

Probably we could make use of "find -type f [-maxdepth 1]", though in Bash as requested that would no longer be necessary.

As for sorting in Awk if numbered indices are not sorted by default with (i in a), we could make use of asort() but that function is still new.
 
Old 07-07-2013, 05:16 AM   #19
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Well Ruby easily handles the file only option:
Code:
if File.file?(f)
 
Old 07-07-2013, 05:32 AM   #20
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
True for Ruby
 
  


Reply



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
Averaging columns from multiple files carlr Programming 3 03-18-2012 01:24 AM
alsa - averaging stereo to mono for speaker output bdjnk Linux - General 0 08-18-2009 02:38 PM
Bash background (&) with control operators (&&) int0x80 Programming 1 02-11-2009 12:54 PM
Bash: Print usage statement & exit; otherwise continue using Bash shorthand operators stefanlasiewski Programming 9 02-07-2006 05:20 PM
Adding 2 more drives to /proc/stat (totalling 4) fishsponge Linux - General 1 09-08-2004 07:00 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:54 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
Open Source Consulting | Domain Registration