[SOLVED] Mv command doesnt work in shell script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers [SOLVED] Mv command doesnt work in shell script
# 1  
Old 07-17-2013
[SOLVED] Mv command doesnt work in shell script

Hi All,

i created the below script to move file with xml extension from one directory to another,but the mv command is not working inside the shell script,

Code:
#!/us/bin/ksh
filepath="/apps/extract"
filename="*.xml"
foldername=2191POB000_$(date +%Y%m%d%H%M%S)
mkdir -p "$filepath/$foldername"
mv "$filepath/$filename" "$filepath/$foldername/"

i am getting the below error when i execute this script,but from command line it works.
Code:
mv: cannot access /apps/extract/*.xml

Any help is much appreciated.

Thanks in advance.

Last edited by jim mcnamara; 07-17-2013 at 01:03 PM..
# 2  
Old 07-17-2013
* will not expand inside quotes, you will have to remove the quotes from that part.

Code:
mv "$filepath/"$filename "$filepath/$foldername/"

# 3  
Old 07-17-2013
Hi ,

Thanks for the reply.
I tried this
Code:
mv  $filepath/$filename $filepath/$foldername/

and it worked

Last edited by Don Cragun; 07-17-2013 at 02:03 PM.. Reason: Remove extraneous backquote and add CODE tags.
# 4  
Old 07-17-2013
Quote:
Originally Posted by Radhas
Hi ,

Thanks for the reply.
I tried this
Code:
mv  $filepath/$filename $filepath/$foldername/

and it worked
Please mark this thread as solved for the future reference of other users. Thanks.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to work command 'cd' in shell script?

I have simple script. like that, I am working on /usr/local/src and also under src folder there is a ft folder #!/bin/ksh #!/bin/bash dirpath="/usr/local/src/ft" echo $dirpath cd $dirpath echo displays ok "/usr/local/src/ft" but that doesn't enter "ft" folder. stays in current... (4 Replies)
Discussion started by: F@NTOM
4 Replies

2. UNIX for Dummies Questions & Answers

why doesnt it work?

I am trying to print out two fields in a file using awk. So, I have got awk -F '\t' 'NF = 2 {print $1 $2 "]"}' two.txt in a script called what.awk When i run this version like this - ./what.awk then it runs however I want to run the program like this awk -f what.awk two.txt. When I... (8 Replies)
Discussion started by: The undertaker
8 Replies

3. AIX

Vi doesnt work

Hi Guys, I have a strange problem.( AIX 6.1) "vi" is not working at all..Whenever i #vi <anythin> ,, it returns the prompt back. Any clues folks?? (14 Replies)
Discussion started by: muzahed
14 Replies

4. UNIX for Dummies Questions & Answers

find command in shell script doesn't work

Hello all, Something strange going on with a shell script I'm writing. It's trying to write a list of files that it finds in a given directory to another file. But I also have a skip list so matching files that are in that skip list should be, well uhm, skipped :) Here's the code of my... (2 Replies)
Discussion started by: StijnV
2 Replies

5. Shell Programming and Scripting

A script doesnt work properly when crontab

Hi, I have a script which does a tar and sends it to another server as backup. Script is as below # Locations to be backed up. Seperate by space BACKUP_LOCATIONS=/repos/subversion BACKUP_BASE_FOLDER=/bakpool BACKUP_FILE_NAME_ROOT=svn-backup START_TIME_DISP=`date` START_TIME=`date... (11 Replies)
Discussion started by: digitalrg
11 Replies

6. UNIX for Dummies Questions & Answers

cp doesnt work - Help

When trying to copy a file in Solaris 8 it doesnt copy file or give a error. This worked 100% until the 29th. I've checked the rights and everything seems fine: drwxrwxrwx 2 bmuser bmgroup 11776 Jan 3 10:32 spool This is the file I want to copy: -rwxrwxrwx 1 bmuser bmgroup ... (26 Replies)
Discussion started by: rudi.okelly
26 Replies

7. Shell Programming and Scripting

find command with exec doesnt work

Hi There, I have a script which finds for log files and removes them if the file has changed in the last day. The script runs fine without errors. The log file is still there. So, I decided to print the find command and run the command outside the script. Getting "Incomplete statement" Can you... (6 Replies)
Discussion started by: funtochat2002
6 Replies

8. HP-UX

ls command doesnt work

Good Day I mistakely renamed the dld.sl file in the /usr/lib directory. When i try to ls/ftp into the box i get this error :eek: crt0: ERROR couldn't open /usr/lib/dld.sl errno:000000002 I have tried to rename it back from the renamed file to the original file name, but it gives me the... (2 Replies)
Discussion started by: shawnbishop
2 Replies

9. UNIX for Dummies Questions & Answers

cd.. doesnt work

hi when i want to go to previous directory by typing cd.. i get the following message $ cd.. ksh: cd..: not found Please help rintingtong (2 Replies)
Discussion started by: rintingtong
2 Replies

10. Shell Programming and Scripting

why doesnt my script work!!!

Is there a utility or command I can use to tell the number of decimal places a number has. For instance, if the number is 432, it will give hundred as the number of decimal places. (7 Replies)
Discussion started by: Heedunk
7 Replies
Login or Register to Ask a Question