The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to navigate previous files one by one. ajayshukla UNIX for Dummies Questions & Answers 5 08-14-2008 12:25 PM
Viewing Directory Content as You Navigate Directories in UNIX shelata UNIX for Dummies Questions & Answers 2 07-28-2008 01:39 AM
How Do I Navigate To A Directory??? kprescod4158 Shell Programming and Scripting 2 01-20-2008 05:24 AM
Can you navigate ABOVE the home directory? patwa UNIX for Dummies Questions & Answers 4 06-13-2007 10:27 PM
need to acces unix box thrugh the internet RuDe_BuT_CoOoL UNIX for Dummies Questions & Answers 4 05-10-2003 10:30 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-03-2009
sussane sussane is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 17
Exclamation script to navigate thrugh directories

Hi,

I have a requiremnet where i need to apply logic on directories and sub-direcotories.

Example:

base="/a/b/c"
base1="/a/b/c/d/e"

subfolders in both base and base1 are same : es, ig, os
var1=es
var2=ig
var3=os

Now i have used the follwoing lines in my code and these are creating problem

for dir in "($base | $base1)/$var1" "($base | $base1)/$var2" "($base | $base1)/$var3"

do
(
echo "The current directory is:"`pwd` >> ${LogFile}
cd "$dir" || continue
for i in *.*
do
(
touch "$i" && printf 'Success: %s\n' "$i" || printf 'Failed: %s\n' "$i" >> ${LogFile}
)

done
)
done



Please suggest on the above code .
while executing for loop it is not working.
  #2 (permalink)  
Old 01-03-2009
Christoph Spohr Christoph Spohr is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 205
Hi,

Code:
for dir in a/b/c/{es,ig,os,d/e/{es,ig,os}}/*
do 
  echo $dir
done
should do it.

HTH Chris
  #3 (permalink)  
Old 01-05-2009
sussane sussane is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 17
Thank you Christoph.

I have used it in script as below. But it did not work for me.

Please suggest.

for dir in "$base"/{"$var1","var2","$var3",d/e/{"$var1","var2","$var3"}/*

touchfiles1.sh[37]: /a/b/c/{es,ig,os,/d/e/{es,ig,os}/*: not found.
  #4 (permalink)  
Old 01-05-2009
Christoph Spohr Christoph Spohr is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 205
There is a closing brace missing.

What my snippet does it iterates through all of your
directories and will print out the files and directories
in them. You should be able to adjust this to your needs.

Perhaps you should describe in greater detail what
you want to achieve. What is your input, what shall
your output be.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:17 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0