Find the answer to your Linux question:
Results 1 to 3 of 3
I have a script which parses for differences in directories listed in a file using egrep and awk I can pick out missing directories but now want to pass this ...
  1. #1
    Just Joined!
    Join Date
    Mar 2009
    Posts
    2

    passing data between scripts

    I have a script which parses for differences in directories listed in a file using egrep and awk I can pick out missing directories but now want to pass this to a mkdir command using some form of redirection i.e. the find / egrep gets me back the paths that are missing, how do I pass individual entries to mkdir simply?

  2. #2
    Linux Newbie
    Join Date
    Mar 2009
    Posts
    228
    Use xargs. For example:

    Code:
    find <whatever> | egrep <whatever> | xargs mkdir -p
    The missing directories will be appended to the end of the mkdir command.

  3. #3
    Linux Enthusiast
    Join Date
    Aug 2006
    Location
    Portsmouth, UK
    Posts
    539
    As Iomcevak has said xargs is what your after.
    If your script to find the missing paths outputs is complex, you might find it easier to pipe that into xargs i.e.

    Code:
    <your script> | xargs mkdir -p
    RHCE #100-015-395
    Please don't PM me with questions as no reply may offend, that's what the forums are for.

Posting Permissions

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