Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
I need to write a script that accepts 3 filenames as command line parameters and test if they are executable and print a message saying whether or not they are, and I need to use a loop.
2. Relevant commands, code, scripts, algorithms:
3. The attempts at a solution (include all code and scripts):
My first attempt works great... but I didn't use a loop
I check to see if you have entered more or less then 3 files to test, displaying errors if you didn't and then test if each file exsists, then test if it is executable.
what my real question is how do I display a different parameter in a loop? I missed the "looping" class as my kid was sick, and we don't use the course book as it's crap.
any help would be great
4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Baker college, Flint, MI, USA, VScott, intro to shell scripting
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
---------- Post updated at 10:43 PM ---------- Previous update was at 09:46 PM ----------
i figured it out, just used a for loop, works like a charm
Moderator's Comments:
edit by bakunin: Congrats on figuring that one out. To celebrate the occasion i ordered a ton of brand new CODE-tags and used two pairs to decorate your code with them. A few more (a gazillion or so) i left here for your own usage as a present - use them wisely. ;-))
Last edited by bakunin; 05-04-2011 at 04:59 AM..
Reason: Code tags, *sighs*
Two comments:
First, your user might appreciate knowing which file(s) don't exist by specifically naming it/them in your message. In the case of three inputs that's not too big of a task for the user to track down, but for a real-world programme, with hundreds or thousands of files to check, I would think it would be advantageous to have a list of specifically what doesn't exist.
Secondly, you might also want to look into using the not (!) operator with your logic:
as it would help you to eliminate the echo > /dev/null. Psuedo code:
Hi evryone
i need a help .
i have a file xcv.the content is :
accelerate
i want a script which will run 1000 times in loop and changing the value to
accelerate to
acceler
in 1st loop and in 2nd loop it will be again
accelerate and so on . (6 Replies)
Hi,
Now I have written a script which sorts the records in the file and splits them according to some condition.
Now, I need to modify the script so that it reads all the files one after the other and does the sorting & splitting.
Pls help me in reading all the files in a directory and... (8 Replies)
I run into a issue when I try to do sorting of the following with ascending order, one round of for looping seems not working, anyone knows how to use shell or perl?
$array = (5,0,3,2,7,9,8) (2 Replies)
This is my requirement--
I have a list file that contains a list of 50 words.
eg
word1
word2
word3
I want to search/grep for each of those words in a directory/and subdirectories and list the file in which that word exists.
Ne ideas for script/command?
I know grep -r <pattern>... (3 Replies)
Hi,
I have series of data stored in a variable xyz:
(between 0 and 100)
example:
20 45 98 21.....
I need to find if there is/are any occurance of data > 95
Not sure what kind of looping is required to check.
Please help.
thanks (2 Replies)
I have an array of hashrefs that look like the following:
my @LAYOUT = (
{SQL_1 => "select count (*) FROM prospect
WHERE PROCESS_DATE = To_date('INSERT_DATE_HERE', 'mm/dd/yyyy')
and tiff_filename is not null
... (2 Replies)
Hi,
I'm having some trouble with the syntax in constructing a simple nested 'for' loop.
My code is as follows:
#!/bin/bash
dir1="fred flume haystack"
for dir2 in ${dir1}
do
fred="1 2 3"
flume="a b c"
... (7 Replies)
I am writing a simple script and want to keep the user in a fuction until they are ready to get out. For some (probably stupid) reason, it doesn't seem to be working. You guys see anything that I'm overlooking?
crsd()
{until
do
/home/wcs3611.crsdtmp.sh
echo 'run another? \c'
... (1 Reply)
Hi,
Actually I have a file which consists data . for eg names.
Then I want my sql query to read this file and produce the output.
Currently I am using this
FOR EG : FILENAME is NAMES
for i in `cat NAMES`
{
sqlplus -s $CONNECTID << EOF
spool rooh
set heading off
select... (1 Reply)