| Raw Input
|
The data file is generated by a 'tar tvf tar_file' command,
where
- the path of an object always begins at 47th column.
- there may be spaces in the paths.
An example of input is as follows:
| rwxrwxr-x john/users 2205 Oct 1 11:49 2001 ./dir1/file1.txt
rwxrwxr-x john/users 0 Sep 13 10:06 2001 ./dir2/
rwxrwxr-x john/users 0 Oct 9 15:24 2001 ./dir2/dir3/
rwxrwxr-x john/users 10422 Oct 9 15:09 2001 ./dir2/dir3/file2.txt
rwxrwxr-x john/users 856 Oct 9 15:16 2001 ./dir2/dir3/file3.txt
rwxrwxr-x john/users 1020 Oct 22 8:16 2001 ./dir2/dir3/file 4.txt
|
|
| Desired Output
|
What we want to do is to
- remove the lines describing directories which always end
with slashes, e.g., the second and the third lines.
- for lines describing files, remove the directory part of its path,
leaving only its basename.
The desired output is:
| rwxrwxr-x john/users 2205 Oct 1 11:49 2001 file1.txt
rwxrwxr-x john/users 10422 Oct 9 15:09 2001 file2.txt
rwxrwxr-x john/users 856 Oct 9 15:16 2001 file3.txt
rwxrwxr-x john/users 1020 Oct 22 15:16 2001 file 4.txt
|
|
Script and Comments
Script1 [ 1] /\/$/d
[ 2] s|^\(.\{46\}\).*/\(.*\)|\1\2|
| |