Jun 8, 2008 #1 krava Programmer Joined Jun 4, 2007 Messages 48 Location YU hi I have file names like: "data1", "esdu2sdt" ... "da15efe" I would just like to extract number from filenames. There is absolutely no rule where the numbers are in the names. How to do this? thanks k.
hi I have file names like: "data1", "esdu2sdt" ... "da15efe" I would just like to extract number from filenames. There is absolutely no rule where the numbers are in the names. How to do this? thanks k.
Jun 8, 2008 #2 risby Programmer Joined Feb 27, 2002 Messages 84 input your filenames on standard input with ls | file_nos.awk where file_nos.awk is Code: #! /usr/bin/awk -f { if (match($1, /[0123456789]+/)) { print substr($1, RSTART, RLENGTH) } } to get Code: 1 2 15 ========================================== abjure hippopotomonstrosesquipedaliophobia Upvote 0 Downvote
input your filenames on standard input with ls | file_nos.awk where file_nos.awk is Code: #! /usr/bin/awk -f { if (match($1, /[0123456789]+/)) { print substr($1, RSTART, RLENGTH) } } to get Code: 1 2 15 ========================================== abjure hippopotomonstrosesquipedaliophobia
Jun 8, 2008 Thread starter #3 krava Programmer Joined Jun 4, 2007 Messages 48 Location YU ok... this works fine....thanks for the tip Upvote 0 Downvote