Hello all,
I'm looking for a way to manipulate the results from the grep command. I'm on a unix system, and I have a file (temp.txt) containing rows such as:
./misc/dir/file1.htm,123
./misc3/dir2/file1.htm,89
./misc/dir/file2.doc,3489
./file3.htm,349
./misc3/dir3/file5.doc,89
(etc)
I want something that will grab only the filename (eg. 'file1.htm') and write only the unique filenames to a new file (no duplicates). I can write a perl script to do this but I was wondering if there was a unix one-liner I could type on the command line to accomplish this.
That is, how do you trim the result from grep (in my perl script I use s/^.*\/(.*),.*/$1/ ), and would you then pipe this to the uniq command?
Thanks in advance,
Scott.
I'm looking for a way to manipulate the results from the grep command. I'm on a unix system, and I have a file (temp.txt) containing rows such as:
./misc/dir/file1.htm,123
./misc3/dir2/file1.htm,89
./misc/dir/file2.doc,3489
./file3.htm,349
./misc3/dir3/file5.doc,89
(etc)
I want something that will grab only the filename (eg. 'file1.htm') and write only the unique filenames to a new file (no duplicates). I can write a perl script to do this but I was wondering if there was a unix one-liner I could type on the command line to accomplish this.
That is, how do you trim the result from grep (in my perl script I use s/^.*\/(.*),.*/$1/ ), and would you then pipe this to the uniq command?
Thanks in advance,
Scott.