Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
-rw-r--r-- 1 root root 964855 jun 1 2011 20110601-102800-1306942080.4314.WAV
-rw-r--r-- 1 root root 702840 jun 1 2011 20110601-103711-1306942631.4351.WAV
-rw-r--r-- 1 root root 1167850 jun 1 2011 20110601-124746-1306950466.4844.WAV
-rw-r--r-- 1 root root 319470 jun 1 2011 20110601-125540-1306950940.4886.WAV
I need to obtain the "20110601-102800-1306942080.4314.WAV"
Any idea how can I get it?
I tried cut, but the spaces between the each column is not uniform.
past cut there's sed, past sed there's awk or shell scripts, past that there's perl or python. sed's enough to do this, the variable spacing can also exist in filenames so you have to be careful with notions of "columns" or "fields".
That text is obviously the output of ls -l. Note that parsing ls is not a recommended way to get a list of filenames. If there are any filenames with whitespace in them, then it becomes much more difficult to safely extract them.
If you would explain exactly what you are trying to do, then we could probably help you to find a better way to do it.
Finally, please use [code][/code] tags around your code and data, to preserve formatting and to improve readability.
As David the H. pointed out, parsing ls is just a bad idea. Even if you insist on gathering filename data with ls, why not use ls -1, or even unadorned ls?
Even better, use find to gather the full names of files you're interested in. Lookup the -print0 option in the manpage to learn how it may help you collect full names more reliably.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.