Monday, 15 September 2014

linux - Finding regular expression in list of files -



linux - Finding regular expression in list of files -

i have several header files in directory format imagen.hd n integer. 1 of these header files contains text 'trans'. trying find image contains look using csh (i need utilize csh purpose - although can phone call sed or perl one-liners) , show corresponding image. show in

here initial unsophisticated approach not work.

#find number of header files in directory set n_images = `ls | grep 'image[0-9]*.hd' | wc -l` foreach n(`seq 1 n_images`) if (`more image$n{.hd} | grep -i 'trans`) show i$n sc c image #this command uses alias set displayed image current within script endif end

i'm not sure wrong above commands not homecoming right image number.

also i'm sure there more elegant 1 line perl or sed solution unfamiliar both

show `grep -l trans image[0-9]*.hd | sed 's/image/i/`

linux perl sed grep csh

No comments:

Post a Comment