'*' not working in shellscript


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting '*' not working in shellscript
# 8  
Old 01-03-2013
Smilie its there.

If i use this command (i.e. mv DIR\abc_*) outside the shell script, its working fine. But not inside Smilie
# 9  
Old 01-03-2013
mv DIR\abc_*
is not the same as
mv DIR\ABC_*
# 10  
Old 01-03-2013
Sorry typing error, its (mv DIR\ABC_*) only. not abc*
# 11  
Old 01-03-2013
Quote:
Originally Posted by Bopty
Tried the same, but still it throwing the error Smilie
Code:
mv: cannot stat `ABC_*': No such file or directory

OK. I'm totally confused.

You say that:
Code:
mv ${DATA_DIR}/ABC_*.dat ${ARCHIVE}

and:
Code:
mv ABC_*.dat ${ARCHIVE}

write a diagnostic message saying that mv can't stat ABC_*
and then you say that:
Code:
mv DIR\abc_* ${ARCHIVE}

works on the command line, but not in your script.

Do you not see that abc_* is not the same as ABC_*.dat, / is not the same as \, and you still haven't told us what the value of ${DATA_DIR} is nor what the value of ${ARCHIVE} is?

I can assure you that you won't get a diagnostic about not being able to stat a file named ABC_* from an attempt to move a file named ABC_*.dat.

What operating system are you using? The confusion between / and \ makes me wonder if you're running on Windows instead of on a UNIX or Linux platform.
# 12  
Old 01-03-2013
Pls post output of ls -l ${DATA_DIR}/ABC_*.dat.
# 13  
Old 01-03-2013
Hi Don,

Thanks for you mail.

Your confusion is due to typing issue. Let me clearly explain you.

1.) I try to move files from one directory to another, so used a below command,

Code:
mv ${DATA_DIR}\ABC_*.dat ${ARCHIVE}

The Value for DATAA_DIR and ARCHIVE are,

Code:
${DATA_DIR} = /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data
${ARCHIVE} = /u01/data/oracle/rms/UPGRMSBATCH/archive

2.) If i run the above mv command inside my shellscript, im getting the error like

Code:
mv: cannot stat `/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_*.dat': No such file or directory

But if i run the same command (i.e:
Code:
mv ${DATA_DIR}\ABC_*.dat ${ARCHIVE}

) outside the shell script, then it works fine.

3.) Instead of using '*' if i used the complete file name (i.e: ABC_20120103) its working fine inside the shell script itself. But i don't want to do that, since n number of files with different date format is present in the directory. So i want to move all the files from data directory to archive directory.

I hope now you are clear with my issue.

Thanks,
Bopty

Last edited by Scrutinizer; 01-03-2013 at 08:17 AM.. Reason: code tags
# 14  
Old 01-03-2013
/ABC and \ABC are not same.
Code:
echo z\ABC
echo z/ABC

You have not published your script, only some lines
Code:
#!/bin/ksh
# if you like to set value for variable, then
DATA_DIR=/u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data
# no spaces after variable name and after = char
ARCHIVE=/u01/data/oracle/rms/UPGRMSBATCH/archive

# will give error if 
# /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_*.dat not include any ABC_*.dat files
mv $DATA_DIR/ABC_*.dat $ARCHIVE
# test your command line
echo mv $DATA_DIR/ABC_*.dat $ARCHIVE
# => you will see the parsed command line => shell try to execute

#     echo /u01/data/oracle/rms/UPGRMSBATCH/RETLforRPAS/data/ABC_*.dat 
# what is the output ?
#     echo $DATA_DIR/ABC_*.dat
# what is the output ?

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Telnet shellscript

cat << EOF | telnet alt1.aspmx.l.google.com 25 HELO verify-email.org MAIL FROM: <check@verify-email.org> RCPT TO: <test@gmail.com> quit EOF Hello, I'm trying to get the result of that execution, and can not see the result or bring it to a txt ... the direct command in ssh running the result... (5 Replies)
Discussion started by: c0i0t3
5 Replies

2. Shell Programming and Scripting

Help with shellscript

I am new in shell script i want to convert .txt file in the format axsjdijdjjdk to a x s j d i j d j j d k (5 Replies)
Discussion started by: sreejithalokkan
5 Replies

3. Shell Programming and Scripting

Needed shellscript for the following

hi all, i need the shell script for he below requirement i had the input file as a_20121217_035120( frmat is a_date_hhmmss) a_20121217_035128 a_20121217_035456 a_20121217_035767 a_20121217_035178 a_20121217_035189 a_20121217_035220 my output should be a_20121217_035456... (0 Replies)
Discussion started by: hemanthsaikumar
0 Replies

4. UNIX for Dummies Questions & Answers

How can I do aliasing in shellscript?

#Example.sh alias rmv 'sh Example2.sh' when i execute exapme.sh alias name not working. how i solve this problem?? (9 Replies)
Discussion started by: arun508.gatike
9 Replies

5. Shell Programming and Scripting

Need help with shellscript

Hello. I am a novince at writing shell scripts but here is the question. I have to write a shell script that does the following: Once executed via crontab, the script should do the following: a. get date/time stamp in for format 10-MAR-05 and b. execute shell script my_script.sh (which... (2 Replies)
Discussion started by: jigarlakhani
2 Replies

6. UNIX for Advanced & Expert Users

shellscript problem

hI, Pls consider the following shell script #!/bin/csh -f sqlplus tkyte/tkyte <<"EOF" > tmp.csh set serveroutput on declare a number:=5; begin dbms_output.put_line( 'a:='||a ); end; / spool off "EOF" The above script does the followin 1)it connects... (1 Reply)
Discussion started by: ravi raj kumar
1 Replies

7. Programming

Shellscript for MQSeries

Iam new to shellscript. 1)How to strart QUERYMANAGER using shellscript. 2)How to put and get messages in MQSeries using shellscripts. 3)iam using local queues . Thanks lot. (0 Replies)
Discussion started by: ram2s2001
0 Replies

8. Shell Programming and Scripting

Another shellscript question

Folks; on a unix server I have a mapping file which holds a list mountpoints of all databases and their mountpoints. tab delimited or colon deliminted..I needed to copy the datafiles from the pristine mountpoints to test's mountpoints in this case. I needed to do this by passing sid name using... (18 Replies)
Discussion started by: jigarlakhani
18 Replies

9. UNIX for Advanced & Expert Users

ftp in Shellscript

Can I do something like this from a shellscript ?: ftp 12.34.56.78 <<! username password put a.c bye ! It does not go through as the login fails. Is there any alternative to do the above requirement? Thanks in advance. Gowrish (3 Replies)
Discussion started by: ggowrish
3 Replies
Login or Register to Ask a Question