handling filespec in bash script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting handling filespec in bash script
# 8  
Old 07-07-2008
from the command line
ls *
output

filename1 filename2 filename3 filename4

directory1:
bashScript1 bashScript2 bashScript3

directory2:
ShellScript1 ShellScript2 ShellScript3

directory3:
C++1 C++2 C++3
___________________________________________________
In my script i want when i do ./test * does the same

filename1 filename2 filename3 filename4

directory1:
bashScript1 bashScript2 bashScript3

directory2:
ShellScript1 ShellScript2 ShellScript3

directory3:
C++1 C++2 C++3


Sorry, i couldn't post my script because im on windows environment, but in case still want me to paste the code, i'd switch to linux.

Thanks.
# 9  
Old 07-07-2008
Well, ls "$@" inside your script should have that effect.
# 10  
Old 07-07-2008
unfortunately didnt work, thats what ive done

'*')

ls "$@"
;;


d)

clear
echo " "
test -f $FileName #check if the name of directory is a valid file
if (($?==0))
then
echo "you have file the same name"
else

test -d $FileName
if (( $? == 0 ))
then
echo "Directory \"$FileName\" allready exist, you are not allowed with overwriting a direcotry."
else
echo " . "
echo" Folder being created..."
sleep 1
echo " . "
sleep 1
mkdir $FileName
chmod 740 $FileName
clear
echo "New Directory \"$FileName\" has been creacted with the following:"
OutputInfo $FileName;
fi
fi
;;


have i missed anything, or where im wrong !!
Thanks.
# 11  
Old 07-07-2008
Your case statement will never match '*', because the calling shell replaces '*' with the matching filenames when you run your script (as I said in my first response).

You would have to turn off globbing in your shell (set -o noglob) before running your script, or else run it using scriptname '*'.

As zaxxon said, it seems kind of silly to write a script to do what ls does perfectly well on its own?
# 12  
Old 07-07-2008
To help you understand what I'm saying, try typing this:

echo *

and this:

echo '*'
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies

2. Shell Programming and Scripting

Help with shell script handling processes

Hello I have a file which has around 120 lines of commands. I am trying to write a shell script like which reads the 'command' file and executes line by line with some additional (common argument) with maximum 6 commands active at a time. Each of these commands when executed takes time... (5 Replies)
Discussion started by: JackyShane_36
5 Replies

3. Shell Programming and Scripting

Help me add Error Handling to my script

Hi all, I have some sections of a script that I am trying to add error handling to. Basically if it returns any error, just continue. This is for a deployment script that i am writing to assist in the deployment of scripts out to other systems. At the top of my KSH script i added this... (5 Replies)
Discussion started by: nitrobass24
5 Replies

4. Shell Programming and Scripting

BASH - Handling background processes - distributed processing

NOTE: I am using BASH and Solaris 10 for this. Currently in the process of building a script that has a main "watcher" daemon that reads a configuration file and starts background processes based on it's global configuration. It is basically an infinite loop of configuration reading. Some of the... (4 Replies)
Discussion started by: dcarrion87
4 Replies

5. UNIX for Dummies Questions & Answers

File handling in bash shell scripting

i am new to shell scripting and stuck at one place in my program. i am reading data from one structured file and extracting some data from particular lines and then writing into the output file. In that reading input file line by line from while loop. while read line do rectype=line... (7 Replies)
Discussion started by: reeta_shri
7 Replies

6. Shell Programming and Scripting

Help with Error Handling on Script

Hi, I need your guys help again. I run a script which check for some process status in a loop. when i check the process some of the process could throw an error, how can i check that inside my script. Thanks, RR (3 Replies)
Discussion started by: rrb2009
3 Replies

7. Shell Programming and Scripting

Help with handling columns in bash

Hi all, I've tried to look answer from various places but cannot get for my problem. I have a file which is tab delimited: column1 column2 column3 1 10 one 2 100 two 3 9 three 4 100... (7 Replies)
Discussion started by: JSStone
7 Replies

8. Shell Programming and Scripting

File handling with bash shell scripting

Hi all, Can anyone guide to get tricks for file handling in bash shell? Thanks in advance. Thanks Deepak (2 Replies)
Discussion started by: naw_deepak
2 Replies

9. Shell Programming and Scripting

File handling in Script

Hi All, How can we handle file operation in scripts. I have written a script that run ok otherwise however the "Cat" operation leaves a process open on the box. Command is like cat "${LASTFILENAME}" | /usr/xpg4/bin/awk -F, '{do{if ($3 == "100" && $4 == "300" && $170 ~ /^abc/) { ... (2 Replies)
Discussion started by: raman1605
2 Replies

10. UNIX for Dummies Questions & Answers

Handling input from a ls in a script

I'm trying to write a script that will handle the input from the ls command in my script so I can then manipulate the data. For example, I want to capture the output of the ls command in my script and then do a differences between the filename received in to another directory. ls |... (1 Reply)
Discussion started by: spookyrtd99
1 Replies
Login or Register to Ask a Question