Often a wildcard test on files is needed.
Because test -f ... or [ -f ... ] have problems with zero or many arguments, and even [[ -f ... ]] has problems, and I have seen some ugly work-arounds,
I suggest the following simple function, to be defined somewhere at the beginning of the script:
It returns status 0 (success) if at least one of the given files was found,
and status 1 otherwise (the return 1 is necessary in case the nullglob option is on).
Examples:
Analogue to file_exists() one can have the functions
and
These 3 Users Gave Thanks to MadeInGermany For This Post:
That would only test the first argument.
If the first matching /tmp/* token is a directory, it would return 1="no file found" regardless if a subsequent token is a file.
Often it has been said that echo is neither portable nor correct.
Here is an input.txt:
line1
line2
-n
line4
-en
line6
-x
line8
Then the following fails with BSD/Linux/bash:
while IFS= read line
do
echo "$line"
done < input.txt
It is elegantly improved by means of an echo... (2 Replies)
how do i "awk" the date after the from only to compare it on a if statement later .
filename example:
server1-ips-ultranoob-ok_From_2012_21_12-23:40:23_To_2012_21_12-23:49:45.zip
what i want o do is compare only the date from the string in "From_2012_21_12" in this case i only want the... (4 Replies)
Hello,
I'm just starting working on it. I'd like to get a tip
For istance if I have a file like:
a b c
d e f
....
and I wanna get:
1a & 2b & 3c
0d & 8e & 4f
.....
I would like to use sed and come up with a regular expression that works.... (3 Replies)
Hi,
I have a wiered problem probably unique to me.
if test -f "${LOGDIRE}/Component_Name.sql"
then
echo "<br>Synchronization success<br>"
else
echo "<br>Sorry! Synchronizing failed"
fi
Considering, the file is present always, the above condition returns different outputs in each... (1 Reply)
I am about to do a script that change the COST so i dont need to change each cost.
The output looks like this.
"OL_ID OL_LINK_COST
----------- ------------
51 10
52 10
53 10
54 10
55 ... (3 Replies)
I need to use tip from machine A serial port to machine B serial port. Can someone point me to an example of the correct cable to use?
Thanks. (1 Reply)