looping some statements


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting looping some statements
# 8  
Old 12-23-2010
thanx Anurag... 1 more quick doubt/ req Smilie
what if the name of the dir 'qwe' is read a command line argument. that is $1 contains the name of the dir. and I need to assign the path1 = "/xyz/abc/123/$1"

The above assignment doesn't seems to be working.
# 9  
Old 12-23-2010
Code:
path1="/xyz/abc/123/$1"

No space on either side of equal sign.
If still doesn't work, Pls post the code and the error you get.
This User Gave Thanks to anurag.singh For This Post:
# 10  
Old 12-23-2010
"NO space" is the key to the success. Smilie thanx Anurag and all for the help. i got my script working perfectly now.
# 11  
Old 12-23-2010
Quote:
Originally Posted by anchal_khare
Try:

Code:
for dir in /xyz/abc/123/qwe /xyz/dfe/123/qwe /xyz/ghi/123/qwe
do
 mkdir -p $dir/dirA $dir/dirB $dir/dirC $dir/dirD $dir/dirE
done

Code:
set -- /xyz/abc/123/qwe /xyz/dfe/123/qwe /xyz/ghi/123/qwe
for i in $*
do
    mkdir -p $i
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Nested looping statements

I cannot get the code below to work correctly. The IF statement works just fine, but not the looping. The inner loop tries to find files for a given vendor; if found, I need to sleep giving another process time to move the files. Once the given vendor's files are gone, then I want to move on to the... (1 Reply)
Discussion started by: dgreene
1 Replies

2. UNIX for Dummies Questions & Answers

if and then statements

I came across a bash script that outputs the forecast for the day and the max temperature but at the end of the day the max temperature disappears ($6) and I am left with "°C" after the forecast. Here is the script: #! /bin/bash curl -s --connect-timeout 30... (7 Replies)
Discussion started by: _light_
7 Replies

3. Homework & Coursework Questions

Using While and If statements

1. The problem statement, all variables and given/known data: Two problems I need solving please. I created a script where the user types in 7 numbers as standard input and each one is then stored in an array. Now I need to perform the following calculations on those numbers: 1) Use a while... (11 Replies)
Discussion started by: jjb1989
11 Replies

4. Shell Programming and Scripting

Using While and If statements

Hi guys, Two problems I need solving please. I created a script where the user types in 7 numbers as standard input and each one is then stored in an array. Now I need to perform the following calculations on those numbers: 1) Use a while loop to determine the largest number in the range. ... (2 Replies)
Discussion started by: jjb1989
2 Replies

5. Shell Programming and Scripting

vi and if statements

Hi I am very new to Unix programming and shell scripting. I am trying t figure out how to write a little script that will output the number of directories. I can find the number of directories using ls -l | grep "^d" | wc -l I can not figure out how to do it so when I type the name... (8 Replies)
Discussion started by: Reddoug
8 Replies

6. Shell Programming and Scripting

Help with IF statements

I am writing a script that does a search for a argument in a file and lists all like occurrences. The script verifies that it is a file and then runs another script that list the lines. My problem is that I need the script to accept a file or a directory and then go to that directory check all... (1 Reply)
Discussion started by: zero3ree
1 Replies

7. Shell Programming and Scripting

Looping through a shell script with sql statements

Hello members, I'm working on the Solaris environment and the DB i'm using is Oracle 10g. Skeleton of what I'm attempting; Write a ksh script to perform the following. I have no idea how to include my sql query within a shell script and loop through the statements. Have therefore given a... (4 Replies)
Discussion started by: novice82
4 Replies

8. Shell Programming and Scripting

Please help on IF statements.

I had different problem scenarios with IF statement. Can any expert please enlighten me on the difference with these scenarios. Thank you. 1st Scenario: testdate=`date +%Y%m` test=`cat /var/log/database0.$testdate*.log | grep "Errors found during processing" | tail -10` if then ... (4 Replies)
Discussion started by: filthymonk
4 Replies

9. UNIX for Dummies Questions & Answers

Else in If Statements

Sorry to be a pain, but how does the else work in the if statements? Ive been making scripts with if statements but i cant get the else statements working. Can you help? (8 Replies)
Discussion started by: chapmana
8 Replies

10. Shell Programming and Scripting

or statements?

how do i do an or in an if-then statement? i tried: if ; then bleh fi how???? (1 Reply)
Discussion started by: Blip
1 Replies
Login or Register to Ask a Question