Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

extract number

Status
Not open for further replies.

krava

Programmer
Jun 4, 2007
48
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.

 
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

==========================================
toff.jpg
abjure hippopotomonstrosesquipedaliophobia
 
ok... this works fine....thanks for the tip
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top