-1

I have file wich has many lines inside

All lines that contain

file=/aaaaaaa/bbbbbbb/cccccc/dddddd.txt

it needs to be stripped to this format

file=/dddddd.txt

i am executing perl in bash somethin like this

perl -i -pe 'regex' /localpath/file.txt

In perl command above in 'regex' i would need command to do it, how to do it ?

Kamil
  • 1
  • General unix questions like this (not specifically related to system administration) should be asked on [unix.se] (or [Stack Overflow](http://stackoverflow.com) if they're basic programming) - this kind of "gimmeh teh c0dez" question isn't really on-topic for Server Fault. – voretaq7 Dec 04 '12 at 17:12

3 Answers3

4

If you just want to extract the file, I would use File::Basename

aif
  • 381
  • 1
  • 8
0
perl -n -e 'print $1.$2."\n"if (/(.+\=)\/.+\/.+\/.+(\/.+)$/)' /localpath/file.txt > newfile.txt

Theres probably more elegant ways to do it.

Rhys
  • 57
  • 7
0
 perl -ne '/(.*=).*\/(.*)$/ && print "$1/$2\n"' /localpath/file
Laurentiu Roescu
  • 2,266
  • 17
  • 17