Error while executing switch case for find and replace specific file. Help Me...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Error while executing switch case for find and replace specific file. Help Me...
# 1  
Old 07-30-2012
MySQL Error while executing switch case for find and replace specific file. Help Me...

Code:
case "$inputs" in
sapte)
find /pools/home_unix/sapte/work/models/model -name "*.xml" exec rm -i {} \;;
ckm1)
find /pools/home_unix/ckm1/work/models/model -name "*.xml" exec rm -i {} 
\;;

I am getting error like as below.
Code:
./menu1.sh: line 144: syntax error near unexpected token `)'
./menu1

.sh: line 144: `ckm1)'

Thanks.. prashant

Last edited by Scott; 07-30-2012 at 07:03 AM.. Reason: Please use code tags
# 2  
Old 07-30-2012
You need an extra ; because find needs one, and the case needs two.

Code:
  blah) find ..... {} \; ;;

I prefer to put the ;; on a new-line:
Code:
case "$inputs" in
    sapte) find /pools/home_unix/sapte/work/models/model -name "*.xml" exec rm -i {} \;
    ;;
    ckm1) find /pools/home_unix/ckm1/work/models/model -name "*.xml" exec rm -i {}  \;
    ;;
esac


Last edited by Scott; 07-30-2012 at 07:07 AM.. Reason: Typo
# 3  
Old 07-30-2012
MySQL

Scott thanks for reply

now i am geting another error which is as below.

Code:
enter option for checking specific user xml files to delete
sapte,ckm1,mdubey,hchede,amukherjee,skedar,averma,dbhatt,vmuthu,stiwari

sapte
find: bad option exec
find: [-H | -L] path-list predicate-list
Hit <ENTER> to continue:



thanks prashantSmilie

Last edited by Scott; 07-30-2012 at 07:14 AM.. Reason: Please use code tags
# 4  
Old 07-30-2012
Missing - for the exec option.

Code:
... -exec ...

# 5  
Old 07-30-2012
ya scott it is working fine thanks for the same...prashant..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find and Replace from specific folders

Hello Experts, Any help is appreciated. I would like to find and replace a string in a specific file ( e.g abc.xml) only for the directories starting with "AB 1.0 DIR". I've 50 sub directories starting with "AB 1.0 DIR". And I would like find the file abc.xml in those sub-directories and... (4 Replies)
Discussion started by: builderj
4 Replies

2. UNIX for Dummies Questions & Answers

Find & Replace with same case letters

I have text with upper and lower case words. I want to find something and replace it with something new. But it should match the case - Meaning - it should replace old upper cased word with NEW upper case word and lower with lower. example: this text is very simple TEXT. now I want to replace... (5 Replies)
Discussion started by: grep_me
5 Replies

3. Shell Programming and Scripting

Find and replace with 0 for characters in a specific position

Need command for position based replace: I need a command to replace with 0 for characters in the positions 11 to 20 to all the lines starts with 6 in a file. For example the file ABC.txt has: abcdefghijklmnopqrstuvwxyz 6abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz... (4 Replies)
Discussion started by: thangabalu
4 Replies

4. Shell Programming and Scripting

find from file and replace with specific text

Dear All, I do not have any knowledge of scripting. I want to replace specific lines of a text file with a specific text. Like I have one file which is "original file" and one file "changes file" which has list of lines which I want to replace in original file with a specific string. I want the... (5 Replies)
Discussion started by: libras
5 Replies

5. UNIX for Dummies Questions & Answers

Switch and replace columns in a file

HP-UX I have a fixed length file like this 9921190625797AE2560 20091001US20091001@@NEWSITE @@ 20091013001X X 01NEW00DNA00007081 @@ SPRINGFIELD @@ ... (2 Replies)
Discussion started by: rs1969
2 Replies

6. Shell Programming and Scripting

Need an awk for a global find/replace in a file, specific column

I am new to unix and awk/sed etc... using C-Shell. Basically, I have a fixed length file that has 4 different record types on it, H, D, V, W all in column 1. I need to change all the W's in column 1 to D's. in the entire file. The W's can be anywhere in the file and must remain in the same... (3 Replies)
Discussion started by: jclanc8
3 Replies

7. Shell Programming and Scripting

Find and replace a string a specific value in specific location in AIX

Hi, I have following samp.txt file in unix. samp.txt 01Roy2D3M000000 02Rad2D3M222222 . . . . 10Mik0A2M343443 Desired Output 01Roy2A3M000000 02Rad2A3M222222 . . (5 Replies)
Discussion started by: techmoris
5 Replies

8. Shell Programming and Scripting

Error: Find the pattern in the file and replace

Hi all, I have requirement where i need to find a pattern and replace it by new word. I used the below perl command echo `perl -p -i -e "s/AbCdEf/PqRsTu/g;" FileName.txt` But I am getting an error as below Can't do inplace edit Not a Owner and the file FileName.txt gets ... (9 Replies)
Discussion started by: shreekrishnagd
9 Replies

9. Shell Programming and Scripting

Help needed in Switch Case

Hi Experts team, i wish to use switch case in unix. my req is case $code in 1111) echo "1111" 1112) echo "1112" *) echo "default" esac see eventhough for particular case 1111 , it is always execute the default statement *), if i code like this. How can handle... (2 Replies)
Discussion started by: spkandy
2 Replies

10. Shell Programming and Scripting

Ignore case sensitive in Case Switch

In a Case switch, how to ignore case sensitive in the test: e.g. case "$field" in "TEST) action1;; *) action2;; esac How to go in action1 in case of $field = TEST , or Test , or test or .... without enumerating all possibilities... Thanks,... (1 Reply)
Discussion started by: annelisa
1 Replies
Login or Register to Ask a Question