Problem Description:
I have a file with the names of files I need to delete. Their format is:
C:\msts\Trains\Consists\#MT_DB_NSE_315.con
C:\msts\Trains\Consists\#MT_DB_NSE_315x2.con
C:\msts\Trains\Consists\#MT_MT 86246 IC Up Rake.con
…
What I need is the bare filename, without the path. E.g., from
C:\msts\Trains\Consists\#MT_DB_NSE_315.con I want to keep only #MT_DB_NSE_315.con
I thought “awk -F\ ‘{ print $NF }’” should do it, but it prints the whole line. The problem seems to be with the backslash. I’ve also tried it escaped (with the backslash) and it doesn’t help.
It wasn’t really made for backslash handling… (In fact it doesn’t what it is supposed to do (return the last bit of a path) in your example due to the backslashes)
Luckily I’ve got Windows running in a VM, so I can transfer the files back to Ubuntu for processing with the Unix tools and then transfer them back to use. The backslashes really can be a problem, because I used to run Cygwin, which uses the forward slashes.