How to use a case stmt in a for loop?


 
Thread Tools Search this Thread
Operating Systems Linux How to use a case stmt in a for loop?
# 8  
Old 07-01-2014
Quote:
Originally Posted by CarloM
Bear in mind that ls -rt $svdumpdir/* might return more than one file per line (unless your ls is aliased to something).
Note that ls never puts more than one filename on a line if the output is not connected to a terminal device. The -1 option is always effectively turned on when ls output is sent through a pipe.
This User Gave Thanks to Don Cragun For This Post:
# 9  
Old 07-02-2014
Just guessing: If using e.g. bash, and if your filenames are built consistently, with the region number in the 13th char, you could move the files without the case statement:
Code:
DEST=(MW MA NW SE SW WE WC)
for ...
mv $svdumpdir/${file} $npacdir/${DEST[${file:12:1}]}/$yyyymmdd.gtt.gz 
... done

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Case sensitive in If loop .

Hi All, select app from the menu: ABC DEF GHI JKL ALL # ALL will select all the apps in the menu echo "Enter your option" read option; if then <execute the below command> elif # option is the 1 selection from menu...not ALL <execute the below command> else (14 Replies)
Discussion started by: Devaraj A
14 Replies

2. Shell Programming and Scripting

Case loop condition

hello, I would like to do exit at the end ie list all errors before exiting How to put the token exit in a variable with a loop ? Thanks function g1 () { case "$1" in (-0-0 | -0-1 | -0-2 | -0-3 | -1-0 | -1-1 | -1-2 | -1-3) # nothing, OK ! ;; (*) echo 'Fatal, $1 = '"'$1'"', Date... (9 Replies)
Discussion started by: amazigh42
9 Replies

3. Shell Programming and Scripting

Case Stmt - Need Help Urgently

Hello All, Need help urgently.. i have a scenario where i have two files 1) mireport_20111406.txt 2) PRLIHSP01_8080.2011-06-11-15_26_31 ---------- I want a query something similar to this algorithm :- Case when file_name is like mireport then extract_date=14-06-2011 when... (4 Replies)
Discussion started by: iamnoone
4 Replies

4. Shell Programming and Scripting

Help With Loop in Case Statement script

I am writing a bash script that asks the user for input and I need it to repeat until the user selects quit.. I dont know how to write the loop for it I searched all over but i still do not get it.. if anyone could help with this it would be greatly apprciated here is my script so far: #!... (2 Replies)
Discussion started by: Emin_Em
2 Replies

5. Shell Programming and Scripting

Help with Dates and SQl stmt?

hi All Please explain the below statement in RED?What does this mean? perl /HDS/common/operations/Quality_Team/Nirvana/WEEKLY_OOPS/sql_dump.pl --sql "select * from WEEKLY_REPORT order by test_case, type" --username=ddb_qa --password=ddb_qa123 --sid=pldeldb --output... (1 Reply)
Discussion started by: SVS_2017
1 Replies

6. Shell Programming and Scripting

Help with awk stmt

Hi All, I have a log file as: cat error.log.tmp1 2010-07-06 23:18:34 Connection Available to xyztestftp.abc.com.my 2010-07-06 23:20:33 Connection Available to xyztestftp.abc.com.my ERROR FTP LOGIN Now I am reading this complete log file if no single occurrence of word "ERROR" (this word... (5 Replies)
Discussion started by: ss_ss
5 Replies

7. UNIX for Dummies Questions & Answers

Including case insensitivity into loop command

I have the following piece of code: for file in *csv; do cat $file >> $newfile; done for file in *CSV; do cat $file >> $newfile; done and would like to know how to combine these two rules into one? The combined rule would then include the case insensitivity that I am looking for. (4 Replies)
Discussion started by: figaro
4 Replies

8. UNIX for Dummies Questions & Answers

Please explain the stmt

hi, Please explain the below stmt. P=1234 var1=:/a/b/c/file.dat printf "%s %s\n" "$" "${var1#?}" Output is: 1234 /a/b/c/file.dat What is #? in printf stmt? by using that the first character( : ) of "var1" variable is not displayed in output. How is that? please explain.. ... (1 Reply)
Discussion started by: srilaxmi
1 Replies

9. Shell Programming and Scripting

case loop... repeat on bad input?

I'm trying to get a case statement to start over if an undefined option is selected... But I am ata loss on how to actually do it. Here is a quick example of what I have. Echo "1) do this/n 2) Do that/n 3) Quit/n Make a selection/n" Read answer Case answer in 1) Dothid;; 2) Dothat;;... (3 Replies)
Discussion started by: trey85stang
3 Replies
Login or Register to Ask a Question