5 Replies Latest reply: Jan 31, 2014 1:17 AM by Dude! RSS

changing directory and list the files

446 Newbie
Currently Being Moderated

Hi ..

     Here is the scenario

/dev/bld/jq/$parmfile/jobs/*/builds > text.txt ..here we need to pass the value of parm file and under the jobs we have n number of jobs..

 

if we move to builds directory ,it will list like this ..2013.03.0    devenv    qaenv..

 

i need to catch these alone in  a text file....

  • 1. Re: changing directory and list the files
    Dude! Guru
    Currently Being Moderated

    I don't understand what you are trying to accomplish.

  • 2. Re: changing directory and list the files
    446 Newbie
    Currently Being Moderated

    Let me explain clearly once again..

     

    /dev/bld/$boards/jobs/*/builds   .... in the /dev/bld path,we are having so many boards, so we are passing the value using parameter file $boards which is in a while loop.

     

    likewise in the jobs directory we are having so many jobs and it should consider all jobs,so i have given */builds.

     

    now under the directory we are having some 3-5 directories as follows  - 2013-02.0   builds  config log(all are directories)

     

    here i need to capture the 2013.02(dir name only ,not the files inside this dir) alone in a text for all boards and jobs in a text file.

     

    i tried it with cd and ls command,but it didn't work out.

  • 3. Re: changing directory and list the files
    Dude! Guru
    Currently Being Moderated

    Sorry, still don't understand what you mean. Perhaps you can show an example including the output you expect. The solution might be using "ls -d" or "find -type d" to limit the results to displaying directories only.

  • 4. Re: changing directory and list the files
    446 Newbie
    Currently Being Moderated

    in this path -/dev/bld/$boards/jobs/*/builds  ..we are having 3 directories - 2013-02.0   builds  config log.

    Here my requirement is to capture the name of these directories alone in a text file

  • 5. Re: changing directory and list the files
    Dude! Guru
    Currently Being Moderated

    mkdir -p d1/d2/a/builds/builds

    mkdir -p d1/d2/b/builds/builds

    mkdir -p d1/d2/a/builds/log

    mkdir -p d1/d2/b/builds/log

    mkdir -p d1/d2/a/builds/2013-02.0

    mkdir -p d1/d2/b/builds/2013-02.0

    touch d1/d2/a/builds/testfile

    touch d1/d2/b/builds/testfile

     

     

    ls d1/d2/*/builds

    d1/d2/a/builds:

    2013-02.0  builds  log  testfile

     

    d1/d2/b/builds:

    2013-02.0  builds  log  testfile

     

    ls -d d1/d2/*/builds/*/

    d1/d2/a/builds/2013-02.0/  d1/d2/a/builds/log/        d1/d2/b/builds/builds/

    d1/d2/a/builds/builds/     d1/d2/b/builds/2013-02.0/  d1/d2/b/builds/log/

     

    echo d1/d2/*/builds/*/

    d1/d2/a/builds/2013-02.0/ d1/d2/a/builds/builds/ d1/d2/a/builds/log/ d1/d2/b/builds/2013-02.0/ d1/d2/b/builds/builds/ d1/d2/b/builds/log/

     

    ls -d1 d1/d2/*/builds/*/

    d1/d2/a/builds/2013-02.0/

    d1/d2/a/builds/builds/

    d1/d2/a/builds/log/

    d1/d2/b/builds/2013-02.0/

    d1/d2/b/builds/builds/

    d1/d2/b/builds/log/

     

    Take your pick. Then to redirect the output to a file, add >/path/filename

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points