Find the answer to your Linux question:
Results 1 to 7 of 7
Good day all, I'm new to this forum. I can use the ls command and it will list all directories and files... But how does one list only list all ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2013
    Posts
    7

    Assign directories name into its own file


    Good day all,
    I'm new to this forum.
    I can use the ls command and it will list all directories and files...
    But how does one list only list all directories ending .that and then take the name of each directory and save them to their own file?
    the .that directories are in /var/mobile/
    This needs to be done in a bash script
    and this is done on ios

    Thanks.

  2. #2
    Linux User sgosnell's Avatar
    Join Date
    Oct 2010
    Location
    Baja Oklahoma
    Posts
    492
    On iOS, I have no earthly idea, and don't even want to know. You need to ask that in an iOS forum.

    On Linux, the command find should do the job, coupled with the > operator. Read the man pages for find and google the redirection operator for Linux. You'll get a better understanding and fuller explanation doing that. Then you'll need to do some research on iOS.

  3. #3
    Just Joined!
    Join Date
    Nov 2013
    Posts
    7
    Thank you, really I wanted some help to get me on my way.. And you did
    However
    find *.this >> file1 only takes the directories ending in .this and put them all into file1
    how can I take each line in file1 and add them to their own file ending in .txt? In bash lest say you did it on Linux...

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Engineer docbop's Avatar
    Join Date
    Nov 2009
    Location
    Woodshed, CA
    Posts
    947
    ls -l | grep '^d' | grep '\.this$'


    The long form of ls, then use grep to get directories only, and use grep again for lines ending in .this

  6. #5
    Just Joined!
    Join Date
    Nov 2013
    Posts
    7
    I used ls -d *.this >> file1
    And that takes the full directory names ending in .this and amends them to the next free line in file1
    but now I need to take each line out of that file and put them into their own files ending in .found and going up in number so 1.found, 2.found, 3.found etc... Depending on how many are found

  7. #6
    Linux User sgosnell's Avatar
    Join Date
    Oct 2010
    Location
    Baja Oklahoma
    Posts
    492
    Is this homework? Homework help is not allowed here...

  8. #7
    Just Joined!
    Join Date
    Nov 2013
    Posts
    7
    Nar, the only supject I have that envolves computers is graphics... I didn't even think bash was a school thing...

Posting Permissions

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