I've got a bunch of files in the form:
Apple (2006-04-11)
Berry (2006-01-13)
I'd like to run ls on the directory containing these files and then pipe only the date portion (YYYY-MM-DD) of the filenames into another file.
Can anyone point me the right direction?
Shell Scripting: Piping part of ls output
Moderator: General Moderators
untested
Code: Select all
ls | sed "s/.*(//g" | sed "s/)//g" > file.list
or
Code: Select all
ls | sed "s/[^0-9-]//g" > file.list
or
cut -d " " -f 2 : display second field of a space-sparated list.
see http://www.gnu.org/software/coreutils/m ... ils_8.html
Code: Select all
ls | cut -d " " -f 2see http://www.gnu.org/software/coreutils/m ... ils_8.html
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Heh, cool, how come I've never seen cut used before?volka wrote:orcut -d " " -f 2 : display second field of a space-sparated list.Code: Select all
ls | cut -d " " -f 2
see http://www.gnu.org/software/coreutils/m ... ils_8.html