Using ls in a script for another directory


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Using ls in a script for another directory
# 1  
Old 06-04-2003
Using ls in a script for another directory

I am trying to recover a listing of moved error files using the ls command.

This is required to check that files that are deemed error are renamed and moved to the apropriate directory. Problem is, I am not able to get the ls /file path/*.fixed to work. I have tried using a variable i.e. ls ${path}/*.fixed. I can rename and move the files but listing them is a headache.

I am hoping that there is a really simple answer to this.

Any way thanks in advance.

Smilie
# 2  
Old 06-05-2003
Try:

ls \/file path\/\*\.fixed

HTH's
# 3  
Old 06-05-2003
I don't understand what the problem is. I can certainly do this....
xxx=/etc
ls $xxx/*.conf

What shell are you using? What system? What happens when you try it?
# 4  
Old 06-05-2003
I have a script that is moving error files (after confirmation from the user). I need to, just as a final confirmatin show the files have been moved.

I am using a ksh, in Solaris.

I have tried a number of ways to try and get this to display.

ATTEMPT 1
PWDIR=/app/icop/aircrews/CIP/data/CMSLOG/log/batch/history
ls -ls ${PWDIR}/*.Fixed

ATTEMPT 2
cd /app/icop/aircrews/CIP/data/CMSLOG/log/batch/history
ls -ls *.fixed
# 5  
Old 06-05-2003
I would expect either to work. I ask again:

What happens when you try?

From your shell prompt, try attempt two. What happens there? Also try just "ls -ls *". Does that work?

It could be that both are working and the files are not there.
# 6  
Old 06-05-2003
I have multiple terminals open, so I can see the files have arrived in the appropriate directory.

I keep getting,

*.fixed: No such file or directory
/app/icop/aircrews/CIP/data/CMSLOG/log/batch/history/*.fixed: No such file or directory
# 7  
Old 06-05-2003
When I do ls from the command line, and your working directory is where I need to list from, it works, but not when run in the script.

/app/icop/aircrews/CIP/data/CMSLOG/log/batch/history $ls -ls *.fixed
8 -rw-r--r-- 1 icopmgr icop 1318 Jun 4 15:05 ADDR0605003136.LOG.fixed
/app/icop/aircrews/CIP/data/CMSLOG/log/batch/history $
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script cannot create directory and move the file to that directory

I have a script, which is checking if file exists and move it to another directory if then mkdir -p ${LOCL_FILES_DIR}/cool_${Today}/monthly mv report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv ${LOCL_FILES_DIR}/cool_${Today}/monthly ... (9 Replies)
Discussion started by: digioleg54
9 Replies

2. Shell Programming and Scripting

What is the function of the following lines at the top of a shell script file: Directory and Script?

The file starts like this: Directory: <path to the script> Script: <script fife name> #!bin/ksh ##Comments <actual script> What is the use of the first two lines in the script? What if I save the file without them? What will be the effect? They are not comments. Im very new to this,... (4 Replies)
Discussion started by: remytom
4 Replies

3. Shell Programming and Scripting

Moving Files one directory to another directory shell script

Hi, Could you please assist how to move the gz files which are older than the 90 days from one folder to another folder ,before that it need to check the file system named "nfs" if size is less than 90 or not. If size is above 90 then it shouldn't perform file move and exit the script throwing... (4 Replies)
Discussion started by: venkat918
4 Replies

4. Shell Programming and Scripting

Shell scripting-I need a script which should watch a directory for a file with specific directory

I need a script which should watch a directory for a file with specific directory. If it finds a file in directory, it should search for few specific keyword in the file. if the keyword exists, it should trim string from specific column. The file should be moved to another directory and the a... (8 Replies)
Discussion started by: akashdeepak
8 Replies

5. Shell Programming and Scripting

Script which removes files from the first directory if there is a file in the second directory

Script must removes files from the first directory if there is a file with same name in the second directory Script passed to the two directories, it lies with them in one directory: sh script_name dir1 dir2 This is my version, but it does not work :wall: set - $2/* for i do set -... (6 Replies)
Discussion started by: SLAMUL
6 Replies

6. Shell Programming and Scripting

script that reads all the scripts in the directory and run them within that script

Hi I am trying to write a shell script that is reading all the scripts in the current directory (currently 5) and is allowing me to run the scripts that is in the directory. I want that this scripts asks te user to execute 1 of the listed scripts. I have 4 sample scripts in the directory:... (8 Replies)
Discussion started by: I-1
8 Replies

7. Shell Programming and Scripting

Run script from the directory it is in

I have a script at /java/custom/build.sh I want to force the user to execute the script from the /java/custom directory ONLY. In other words if the user is in /java I want to exit if they execute custom/build.sh The directory structure may change from the env to env, so I can't use... (4 Replies)
Discussion started by: t_c_1980
4 Replies

8. UNIX for Dummies Questions & Answers

Script to find a string in a directory/sub-directory

I'm trying to find this string 'preparing string IBE_Quote_W1_Pvt.SaveWrapper for quote_header_id’ in my Apache log file directory. The log file that contains this string may be in a parent direcotry or a sub-directory. I have tried 'grep' and 'awk' with no success. I would like to get the path... (3 Replies)
Discussion started by: gross
3 Replies

9. Shell Programming and Scripting

Executing script's directory

I have a shell script /home/user1/bin/sh1, how can I print out the directory of this file inside the script. Say I am in /home/user1/, then I run /home/user1/bin/sh1 I need it to print out /home/user1/bin. Thanks. (2 Replies)
Discussion started by: jasony001
2 Replies

10. Solaris

running script in any directory

hi im a cobol programmer but im new in unix. I just want to know how can i run script even if it is in other directory?? Thanks, (1 Reply)
Discussion started by: shinjeck
1 Replies
Login or Register to Ask a Question