Get matching string pattern from a file

Hi,

file -> temp.txt
cat temp.txt

/home/pradeep/123/a_asp.html
/home/pradeep/123/a_asp1.html
/home/pradeep/435/a_asp2.html
/home/pradeep/arun/abc/a_dfr.html
/home/pradeep/arun/123/a_kir.html
/home/pradeep/123/arun/a_dir.html
....
....
..

i need to get a_*.html(bolded strings alone) in another file.

kindly help.

thanks,
Pradeep.

sed 's:.*/::' temp.txt >anotherfile
for i in `cat temp.txt`
do echo "${i##*/}"
done >anotherfile
awk '{sub(".*/",z)}1' temp.txt >anotherfile
1 Like
awk -F"\/" '{print $NF}' temp.txt
1 Like
 
perl -lne 'print /\/(\w+\.html)/g'  temp.txt
1 Like

thank u all :slight_smile: it works!!