hi,
how can i take the file names from a directory and store only the filenames in the file.
suppose i have a directory which contains the following files and subdirectories.
$ ls -ltr
total 16
-rw-rw-r-- 1 adm etc 4 Aug 6 20:37 s1.txt
-rw-rw-r-- 1 adm etc 4 Aug 6 20:37 s2.txt
-rw-rw-r-- 1 adm etc 6 Aug 6 20:37 s3.txt
drwxrwxr-x 2 adm etc 4096 Aug 7 21:23 ARC
i want to select only the filenames excluding the directories and send the file names to a temp file. how can i do this. the output should be:
is it always 9 column when we use ls -ltr? i tried this before but for some location i was getting it correctly and sometimes it was picking up some other column. is there a way so that i can always get the last column instead of hard coding the column number? i tried using
will do it will look for further directories in Home and check the files there too, so to make a differance between the other directory files and Home directory files it shows complete path as
/home/s1.txt
for files which are presnet there.
Please let me know if this helps or if you need any assistance please.
Let me share an example with you hope this will help you more.
Let's say I want to see all ksh files at "/home/user/bin/singh_testing/*.ksh
same you can put here .txt in place of ksh please.
ls -ltr /home/user/bin/singh_testing/*.ksh | awk -F"/home/user/bin/singh_testing/" '{print$2}'