Cannot find Error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cannot find Error
# 1  
Old 01-07-2014
Cannot find Error

Today is my first day in shell scripting.
I am not able to find error.
Need Help!

Error is :-
syntax error near unexpected token `then'
test.sh: line 50: ` if[-n "$patha"]; then

Code:
echo "Enter Path o(if empty file will be unzipped to /var/www/):"             read path              
echo "Enter Old domain name(default is local.cms.com):"             
read old              

if[-n "$path"];    then                         ======>Error in this line.
         if [ -n "$old" ]; then                     
           grep -r "$old" "$path"                     
            echo "Enter New domain name:"
           read new                     
           if [ -n "$new" ]; then 
               grep -rl "$old" "$path" | xargs sed -i "s/$old/$new/g" 
           else 
             echo "Cannot be empty"                                                  
          fi                   
         else                     
            old="local.cms.com"                     
              grep -r "$old" "$path"                     
           echo "Enter New domain name:"                     
            read new                         
              if [ -n "$new" ]; then                             
grep -rl "$old" "$path" | xargs sed -i "s/$old/$new/g"                         
else 
    echo "Cannot be empty"                                                          
fi                  
fi              
  else                 
   echo "Invalid Path"             
fi

# 2  
Old 01-07-2014
Add a space after '[' and before ']' like:
Code:
if [ -n "$path" ]

instead of:
Code:
if[-n "$path"]


Last edited by Franklin52; 01-07-2014 at 08:01 AM..
This User Gave Thanks to Franklin52 For This Post:
# 3  
Old 01-07-2014
try giving proper spaces after
Code:
if

statement
This User Gave Thanks to zozoo For This Post:
# 4  
Old 01-07-2014
Thanks Both Of You Smilie

---------- Post updated at 06:32 AM ---------- Previous update was at 06:30 AM ----------

Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find command error

Hi, We have a shell script which looks into a directroy for any folder older than 30 days and removes them. The command being used is find $ARCHIVE_DIR -type d -mtime +$PURGE_HIST_DAYS -exec rm -rf {} \; It removes some folders but then throw below errors for others: find:... (2 Replies)
Discussion started by: DejaVu
2 Replies

2. Shell Programming and Scripting

find error?? find / -name "something.txt" 2>/dev/null

why is this giving me errors? i type this in: find / -name "something.txt" 2>/dev/null i get the following error messages: find: bad option 2 find: path-list predicate-list :confused: (5 Replies)
Discussion started by: magiling
5 Replies

3. Programming

Find out the error

Please see the error below Program: #include<stdio.h> #include<sys/types.h> #include<sys/mman.h> #include<stdlib.h> #include<fcntl.h> #include<sys/stat.h> #include<unistd.h> #include<signal.h> #include<string.h> main(int argc, char *argv) { int fd,changes,i,random_spot,kids;... (1 Reply)
Discussion started by: gokult
1 Replies

4. UNIX for Dummies Questions & Answers

find - link - error

Have a random question: In simple terms I have a find command on a dir: /path/user/data/ /path/user is a link to: /tmp/storage/ The find command outputs the files it finds as: /path/user/data/file What I need is: /tmp/storage/file Is there a way to "resolve" the Unix... (5 Replies)
Discussion started by: Cranie
5 Replies

5. UNIX for Advanced & Expert Users

error with find

for FNAME in `find . -type f -exec grep -il unixs317 {} \;`; do C=`grep -c unixs317 ${FNAME}`; echo "${C}:${FNAME}" >> output.txt; done When I run this command and a directory is empty it is returning an error and just does nothing more. How can I continue with my search even when it find... (3 Replies)
Discussion started by: TimHortons
3 Replies

6. Shell Programming and Scripting

syntax error not able to find why

Hi Guru's here is part of my shell script where the error is coming. function daemon_start { daemon="" clear :<<COMMENT Meenakshi 25-Jun Code Cleanup IA - code comented - Start echo " `date` ... (1 Reply)
Discussion started by: namishtiwari
1 Replies

7. Shell Programming and Scripting

find error

I have a directory that our applications are continuely generate new file to it , some files hv a word "error" in content , I would like to find out which file hv this word and send me notify mail to inform me which file hv this word , currently , I have a stupid script to grep the word , the... (1 Reply)
Discussion started by: ust
1 Replies

8. AIX

Error: could not find any of these C compilers

Hi, While trying to configure Apache Web Server on P630 Server i am getting the below message "Creating Makefile in src + configured for AIX 5.2 platform Error: could not find any of these C compilers anywhere in your PATH: gcc cc acc c89 Configure terminated" when i did a "lslpp -l... (2 Replies)
Discussion started by: cherryven
2 Replies

9. UNIX for Dummies Questions & Answers

error in a remote find

2 AIX servers (AIX 5.3). From local server, I need to manage remote files. But I have some errors with find : # rsh remoteserver find /directory -name filename is OK : I can see the remote file BUT : # rsh remoteserver find /directory -name filename -exec ls -l {} \; fails : I have : find :... (5 Replies)
Discussion started by: annemar
5 Replies

10. Shell Programming and Scripting

Error when using if [ find '

I am trying to issue the following command in script: if ; then and I am getting the following error: bad number Any ideas Rgds Joe (4 Replies)
Discussion started by: berminator
4 Replies
Login or Register to Ask a Question