Find the answer to your Linux question:
Results 1 to 3 of 3
how do i create a srcipt that will produce a text file with currently listing of diretory i know that "ls -a" is listing all directory, but how to make ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2005
    Posts
    2

    newbie script question


    how do i create a srcipt that will produce a text file with currently listing of diretory

    i know that

    "ls -a" is listing all directory, but how to make it produce a view in text file?

  2. #2
    Just Joined!
    Join Date
    Sep 2005
    Posts
    5
    I think you're asking how to redirect the output of "ls -a" to a file. That is done as follows:
    Code:
    ls -a > directory_listing.txt

  3. #3
    Linux Guru bigtomrodney's Avatar
    Join Date
    Nov 2004
    Location
    Ireland
    Posts
    6,133
    That's the standard redirect and works for all occasions, best suited for a one off command in a script I find.

    Using >> will append to an existing file or create it if it doesn't or if you want to see the output on screen as well as redirecting it you can use tee
    Code:
    ls -a |tee foo.txt

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •