Is this a valid statement?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Is this a valid statement?
# 1  
Old 03-07-2005
Is this a valid statement?

I need an if statement that recognizes whether files fitting a certain pattern exist in the current directory. Is this syntax valid:
Code:
if [ -f "filename.ext.${zero}${star}" ]; then
...
fi

assuming that zero="0" and star="*". Is there a better way to write it?
# 2  
Old 03-07-2005
It didn't work as written - but if you remove the quotes around "filename.ext.${zero}${star}" then it works (with ksh).
# 3  
Old 03-08-2005
IF you are filename is as filename.log0* then, it will work normally as,

if [[ -f filename.log0* ]]
then
...
fi

If you want to do check filename.log01, filename.logo2,....filename.log0n then,

for file in `ls filename.log0*`
do
echo $file
done

HTH.
# 4  
Old 03-08-2005
Uuoc

Quote:
Originally Posted by muthukumar
for file in `ls filename.log0*`
do
echo $file
done
HTH.
UUOC

for file in filename.log0*
......
......
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert Update statement into Insert statement in UNIX using awk, sed....

Hi folks, I have a scenario to convert the update statements into insert statements using shell script (awk, sed...) or in database using regex. I have a bunch of update statements with all columns in a file which I need to convert into insert statements. UPDATE TABLE_A SET COL1=1 WHERE... (0 Replies)
Discussion started by: dev123
0 Replies

2. Shell Programming and Scripting

Determine the string is valid

Dear All, I have a string "1234567899*0#123456789#", it can be divided into: - 1st: 1234567899 Validation: 10 digits, only 0-9 - 2nd: *0# Fixed Value - 3rd: 123456789 Validation: 9 digits, only 0-9 - 4th: # Fixed Value Would like to know if any 1 line statement perl,... (5 Replies)
Discussion started by: jimmy_y
5 Replies

3. UNIX for Dummies Questions & Answers

Testing for valid DC's?

Ok so this is sort of a unix question. I am frequently logging into customers boxes and our product integrates with Active directory. I deal with a great deal of people who have no business being admins but are and they don't know squat about their network or their DC's. So a recurring problem... (4 Replies)
Discussion started by: MrEddy
4 Replies

4. Homework & Coursework Questions

Valid Name

Could someone help me by midnight tonight!!! 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: Insert a reference to the Bourne shell as the command... (0 Replies)
Discussion started by: cody007
0 Replies

5. Shell Programming and Scripting

Specified substitution not valid for

Experts, In a script i get the following error: The specified substitution is not valid for this command Do you have any idea what is wrong with it? TITLE="Code Checker" # Script Titel # EXT="_UA99" # Eind van dirnaam # FILE="job.dat" # Zoekbestandsnaam # SEARCH="returncode 0" #... (1 Reply)
Discussion started by: klaasjan
1 Replies

6. Programming

is it valid output ?

#include <iostream> #include<stdio.h> using namespace std; class a { public: int xx; a() { cout << "in CONS a \n"; } ~a() { cout << "in DES a \n"; } }; (1 Reply)
Discussion started by: crackthehit007
1 Replies

7. Shell Programming and Scripting

': not a valid identifier

I am trying to write a bash script. I am able to do simple things like pass arguments, assign variables and echo the results. However, when I try to declare and array or anything a little more complicated I get ': not a valid identifier Here is my code so far: #!/bin/bash echo start t... (7 Replies)
Discussion started by: script123
7 Replies

8. Programming

valid code?

hey , everyone. I have a few questions about pieces of code and was wondering if someone could tell me what exactly they did or if they are even valid. bool1 && bool2 || bool3 <---in what order do these get processed? if (! isdigit(c)) <---What does this do? i = j % 3; <---what does this do?... (4 Replies)
Discussion started by: bebop1111116
4 Replies

9. HP-UX

Valid ranges for uids for HP-UX

Hi , I am using adduser in hp-ux to create users in Hp-ux. i would like to know what are the valid values for uids and gids in hp-ux what are the rannges for the valid uids . How to check what are the used uids in Hp-ux . Thanks Narendra babu C (7 Replies)
Discussion started by: naren_chella
7 Replies
Login or Register to Ask a Question