Find the answer to your Linux question:
Results 1 to 2 of 2
Hi - Very new to this shell scripting/Linux scripting. I have this below and need help. subject_dir=/labs/tricam/MERIT/MERIT_0* for subject in `ls $subject_dir` ; do if [ ! -d $subject_dir/$subject/feat/glm2010/doublegz/SRRTA.feat ] ...
  1. #1
    Just Joined!
    Join Date
    May 2010
    Posts
    1

    Shell Script Help!!!

    Hi -

    Very new to this shell scripting/Linux scripting. I have this below and need help.


    subject_dir=/labs/tricam/MERIT/MERIT_0*

    for subject in `ls $subject_dir` ; do
    if [ ! -d $subject_dir/$subject/feat/glm2010/doublegz/SRRTA.feat ] ; then

    sed 's/MERIT_001/'${subject}'/g' dgA.fsf>${subject}dgA.fsf
    feat ${subject}dgA.fsf
    else
    echo "$subject has already been run"
    fi
    done

    I would like to return the directories in subject dir, but only the directory without path. i.e. MERIT_001, MERIT_002, MERIT_003

    Then I would like to use the sed command in the "fsf" (a text file for another program) to replace with that list. i.e. MERIT_001 replaced with MERIT_002. Do this for all directories that start MERIT_0*.

    When it creates the new file as shown, will it pull it from the right directory when feat starts (another program)?

    -brainscanfmri

  2. #2
    Linux User
    Join Date
    Nov 2009
    Location
    France
    Posts
    292
    return the directories in subject dir
    Code:
    ...
    for subject in `find $subject_dir -maxdepth 0 -type d` ; do
    subject=${subject##*/}
    ...
    0 + 1 = 1 != 2 <> 3 != 4 ...
    Until the camel can pass though the eye of the needle.

Posting Permissions

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