ls > file - Creating file containing the list of all files present in a directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ls > file - Creating file containing the list of all files present in a directory
# 1  
Old 09-26-2008
CPU & Memory ls > file - Creating file containing the list of all files present in a directory

Hi All,

I need to create a file which contains the list of all the files present in that directory.

e.g.,

Code:
ls /export/home/user/*.dat > list_file.dat

but what i am getting is:
Code:
$ ls /export/home/user/*.dat > list_file.dat
/export/home/user/*.dat: No such file or directory

But I have the following contents:
Code:
$ ls /export/home/user/*.dat
/export/home/user/a.dat
/export/home/user/b.dat
/export/home/user/c.dat


I am using KSH on a Sun Solaris 5.10 server. Please tell me in case more specifications are required.

Thanks,
Pranav
# 2  
Old 09-26-2008
ls -1 /export/home/user/*.dat >file1

cat file1 ,u get :
/export/home/user/a.dat
/export/home/user/b.dat
/export/home/user/c.dat
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Total record count of all the file present in a directory

Hi All , We need one help on the below requirement.We have multiple pipe delimited .txt file(around 100 .txt files) present on one directory.We need the total record count of all the files present in that directory without header.File format as below : ... (8 Replies)
Discussion started by: STCET22
8 Replies

2. Shell Programming and Scripting

Systemd errors of missing file “No such file or directory” inspite of file being present

The contents of my service file srvtemplate-data-i4-s1.conf is Description=test service for users After=network.target local-fs.target Type=forking RemainAfterExit=no PIDFile=/data/i4/srvt.pid LimitCORE=infinity EnvironmentFile=%I . . . WantedBy=multi-user.target (0 Replies)
Discussion started by: rupeshkp728
0 Replies

3. Shell Programming and Scripting

How to copy all the contents of a list of files present in a folder to a particular file?

Hi All, I want to copy all the contents of a list of files in a folder to a particular file. i am using following command: cat dir/* >> newFile.txtIt's not working. Could you please help? Thanks, Pranav (3 Replies)
Discussion started by: Pranav Bhasker
3 Replies

4. UNIX for Dummies Questions & Answers

Need help how to create a file (xml) list all files from directory

I have more than 10K songs in two directories on a hard drive. I would like to create a file list all of files name then change to .xml extension to upload to iPhone so I have a Karaoke list on my iPhone. I need your help to create a file by using command in Linux. Files names: 0001 More... (4 Replies)
Discussion started by: ggcc
4 Replies

5. Shell Programming and Scripting

List file NOT present in other directory

Dear community, I have one LOG directory with some files. What I need to do is list ONLY the files that are not present in other directory. Using Bash programming! LOG DIR | SYNC DIR FILE1 | FILE1 FILE2 | FILE3 FILE3 | OTHER FILENAME FILE4 ... (9 Replies)
Discussion started by: Lord Spectre
9 Replies

6. Shell Programming and Scripting

Script to list files not present in audio.txt file

I am having following folder structure. /root/audios/pop /root/audios/jazz /root/audios/rock Inside those pop, jazz, rock folders there are following files, p1.ul, p2.ul, p3.ul, j1.ul, j2.ul, j3.ul, r1.ul, r2.ul, r3.ul And I have a file named as "audio.txt" in the path /root/audios,... (11 Replies)
Discussion started by: gopikrish81
11 Replies

7. UNIX for Dummies Questions & Answers

Creating a list of files in directory?

Hi All, I would like to do a loop on all the files with extension .out in my directory this files should be sorted alphabetically. Then I need to assign to each of them a progressive ID of three digits (maybe in HEX format?). First I tried to list manually the files as ARRAY=( A-001.out ... (5 Replies)
Discussion started by: f_o_555
5 Replies

8. UNIX for Dummies Questions & Answers

Creating a file to count how many files in the directory

hello there i want to creat a file that count how many files i have in the directory. for this i use the command find . -type f | wc -l > 1In1.myfile the problem with this command is that it not update after i add a new file in the directory. Anyone got any ideas how i can... (5 Replies)
Discussion started by: AntiPin
5 Replies

9. Shell Programming and Scripting

How to Check whether list file present in TXT file exist or not

Hi All, I have txt file which has list of files. I have to check whether these files exist or not. Thanks supriya (6 Replies)
Discussion started by: supriyabv
6 Replies

10. Shell Programming and Scripting

ksh: How to get latest file from a list of files in a directory

Hi, I need to get the latest file from a list of files in a particular directory. Please could anyone help me out to get the file. Thank you, - Jay. (1 Reply)
Discussion started by: Jayathirtha
1 Replies
Login or Register to Ask a Question