First off, I should say that I posted a similar query about pathnames (specifically how to remove them) on linuxquestions quite recently and it was helpfully answered. The following question is a little different....:
I am have trouble getting the ls command to work exactly how I want, for example, sometimes I want to list the contents of a directory into a text file by command:
Code:
ls directory > list.txt
(assume the only objects the directory contains are files with extension .dat eg file1.dat, file2.dat, ...)sometimes I want the relative path of the files prepended to them in my text file eg:
path/file1.dat
path/file2.dat
path/file3.dat
etc....
other times I want just the file name and not the path, eg.:
file1.dat
file2.dat
file3.dat
etc.
It feels like ls is unpredictable in this regard - sometimes it prepends the path and sometimes it doesn't and sometimes it adds both entries (with and without the path prepended into the text file)....How can better control the way ls works?