ls > file - Creating file containing the list of all files present in a directory | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

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

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 09-26-2008
pranavagarwal pranavagarwal is offline
Registered User
 
Join Date: Oct 2007
Last Activity: 13 May 2013, 11:46 AM EDT
Location: India
Posts: 29
Thanks: 2
Thanked 0 Times in 0 Posts
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
Sponsored Links
    #2  
Old 09-26-2008
RahulJoshi's Avatar
RahulJoshi RahulJoshi is offline
Registered User
 
Join Date: Aug 2008
Last Activity: 13 September 2013, 10:47 AM EDT
Location: PUNE
Posts: 146
Thanks: 0
Thanked 1 Time in 1 Post
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
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script to list files not present in audio.txt file gopikrish81 Shell Programming and Scripting 11 07-29-2011 02:39 PM
Creating a list of files in directory? f_o_555 UNIX for Dummies Questions & Answers 5 11-30-2009 01:53 AM
Creating a file to count how many files in the directory AntiPin UNIX for Dummies Questions & Answers 5 11-22-2009 05:34 PM
How to Check whether list file present in TXT file exist or not supriyabv Shell Programming and Scripting 6 05-28-2009 09:14 AM
ksh: How to get latest file from a list of files in a directory Jayathirtha Shell Programming and Scripting 1 06-24-2003 10:23 AM



All times are GMT -4. The time now is 12:45 PM.