mv command is giving error in shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting mv command is giving error in shell script
# 1  
Old 12-13-2007
mv command is giving error in shell script

Hi,

In my shell script when I am using mv command using shell variables it is giving me error of syntax. Following is the shell script:

file_edifice="*.txt"
fquote="'"
fdquote=\"

for file in $file_edifice
do
file_name=$fquote$file$fquote
tofile_name=`date "+%d%m%y:%H%M%S:edifice.data"`
echo $filename
echo $tofile_name
mv $file_name $tofile_name
sleep 2
done


errors :

'ACADEMY SPORTS_ACADEMY SPORTS_20071208.txt'
131207:011618:edifice.data
Usage: mv [-f] [-i] [-e warn|force|ignore] f1 f2
mv [-f] [-i] [-e warn|force|ignore] f1 ... fn d1
mv [-f] [-i] [-e warn|force|ignore] d1 d2

'BOSCOVS_BOSCOVS_20071208.txt'
131207:011620:edifice.data

mv: 'BOSCOVS_BOSCOVS_20071208.txt': cannot access: No such file or directory

'DICKS SPORTING GOODS_DICKS SPORTING GOODS_20071208.txt'
131207:011622:edifice.data
Usage: mv [-f] [-i] [-e warn|force|ignore] f1 f2
mv [-f] [-i] [-e warn|force|ignore] f1 ... fn d1
mv [-f] [-i] [-e warn|force|ignore] d1 d2

'SPORT CHALET_SPORT CHALET_20071208.txt'
131207:011624:edifice.data
Usage: mv [-f] [-i] [-e warn|force|ignore] f1 f2
mv [-f] [-i] [-e warn|force|ignore] f1 ... fn d1
mv [-f] [-i] [-e warn|force|ignore] d1 d2

'THE SPORTS AUTHORITY, INC._THE SPORTS AUTHORITY, INC._20071208.txt'
131207:011626:edifice.data
Usage: mv [-f] [-i] [-e warn|force|ignore] f1 f2
mv [-f] [-i] [-e warn|force|ignore] f1 ... fn d1
mv [-f] [-i] [-e warn|force|ignore] d1 d2

Please suggest.

Thanks,
gammit
# 2  
Old 12-13-2007
Quote:
Originally Posted by gammit
Please suggest.
You are trying to make life much harder than it needs to be.

Especially your $fdquote thing.

The shell interprets many characters and I can't tell if you are trying to assist or confuse the hell out of the interpretor.
# 3  
Old 12-13-2007
thanks for your views porter, so what should I do in this case?
# 4  
Old 12-13-2007
You dont need fquote and fdquote, just use quotes where you need them. It will honestly make it much clearer. The syntax to shell scripts hasn't changed much in 25 years, these things don't need to be variables.

also you don't need the sleep.

Once you've simplified it, then repost it and we can have another look. Smilie
# 5  
Old 12-13-2007
thanks porter, it has been resolved.
# 6  
Old 12-13-2007
Excellent,

Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Find command giving bad status error

In a fastload teradata utility I am trying to delete the files which are older than 30days using the find and rm command as following. find . -name 'xxx_*' -mtime +30 -exec rm -f {} \; I expect it to delete all the files older than 30 days but sometimes it gives an error : find: bad status--... (3 Replies)
Discussion started by: stelkar
3 Replies

2. Shell Programming and Scripting

Sql command inside shell script runs without giving anything back as outout

#!/bin/sh # This script returns the number of rows updated from a function echo "The execution is starting ....." sqlplus -silent $UP <<EOF set serveroutput on set echo off set pagesize 0 VAR no_rows_updated NUMBER; EXEC :no_rows_updated :=0; DECLARE CURSOR c_update is SELECT * FROM... (4 Replies)
Discussion started by: LoneRanger
4 Replies

3. HP-UX

HP-UX: Shell Script giving " 0^J30: Syntax error"

Hi All, We are getting a very unique error while running a shell script on HP-UX box. Can somebody help in this regards? The shell script is working fine on linux/solaris box. Error: ++++++++++++++++++++++++ $/test.sh ./test.sh: 0^J30: Syntax error $ ++++++++++++++++++++++++ TIA.... (16 Replies)
Discussion started by: vai_sh
16 Replies

4. Shell Programming and Scripting

Shell command execution always giving zero as return value

Whenever the shell script is invoked by the scheduler the command execution return code is always captured as 0(Success). If the same shell script is executed in command line via unix terminal, the command execution return code's are captured properly. For example: ls -ltr es_wrong_file ---->... (5 Replies)
Discussion started by: vemal
5 Replies

5. Shell Programming and Scripting

Disk Monitoring shell script giving incorrect information

Hi All, OS: Linux 86x64 bits Red Hat Linux I get the email alert for the following when Alert condition is set for 30: /dev/sda1 99M 21M 74M 22% /boot -> Below 30%(Should not get the email alert) Expected output as per E-Mail alert: /dev/sda3 20G ... (2 Replies)
Discussion started by: a1_win
2 Replies

6. AIX

RSH command is giving error (connection refused)

All, I am using AIX 5.3. while running the rsh command I am getting below error message. ------------------ A remote host refused an attempted connect operation. ------------------ .rhost file is updated with correct entry on both the servers. I.e. Login ID Server name in /etc/hosts... (12 Replies)
Discussion started by: anshu ranjan
12 Replies

7. Linux

acroread command giving error

Hi, When I run the command acroread it is giving error ERROR: Cannot find installation directory. When I look at /usr/local/Adobe/Acrobat7.0/bin/ an exicutable file named acroread is there. When i run ./acroread from that directory it is working . What can i do so that I can give... (3 Replies)
Discussion started by: iamjayanth
3 Replies

8. Shell Programming and Scripting

In ksh shell command - Print "-ABC" is giving error

Hi Guys, while executing the following command : print "-ABC" is giving following error : ksh: print: bad option(s) I cannot use echo for some other reasons, so any other option ? (2 Replies)
Discussion started by: sagarjani
2 Replies

9. Shell Programming and Scripting

Cron job giving error while running SSH command

Hi All, The script which i am using to SSH to remote server is working fine when i run is using ./ but when cron runs it it gives error that "ssh: not found" please help!!! (3 Replies)
Discussion started by: visingha
3 Replies

10. UNIX for Advanced & Expert Users

script giving error

Hi All, i have an small issue... echo " " eval x=$@ export x=`echo $x` echo $x ssh user@ipadrss; cd /mbbv/home/; cd /mbbv/home/orange/orange/ echo pwd bash samplescript.sh $x above is my script which will triger from server A and will connect to server B for some... (2 Replies)
Discussion started by: Shahul
2 Replies
Login or Register to Ask a Question