Sponsored Content
Top Forums Shell Programming and Scripting test if a filename exists with specified string (ksh) Post 302103655 by Perderabo on Friday 19th of January 2007 10:41:33 PM
Old 01-19-2007
The thing is that *$var could match mutliple items and perhaps only one of them is file. So a secure solution would be to loop through them all to see if *$var matches a file or not. If you are very sure that *$var will match 1 or 0 files then you could use the single bracket if statement:
if [ -f *$var ] ; then echo match found ; fi
But this will do various things if *$var matches 2 or more items.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to test filename is file or directory

hi all plz let me how to test output of "tail -1 filelist.lst" is file or directory. regards -Bali Reddy (1 Reply)
Discussion started by: balireddy_77
1 Replies

2. Shell Programming and Scripting

ksh - test if string contains alphanumeric...

Okay I will let users input spaces as well :) I am having a mental block. I have done a couple of searches but havent found anything that I understand (the likes of :alpha: and awk). Basically I want to give the user an option to enter some text which will go down as a field within a flat... (3 Replies)
Discussion started by: tugger
3 Replies

3. Shell Programming and Scripting

Problem when test to see if directory exists

Hi, I'm writing a shell script that will create a folder if it does not exist yet. Here's the script: (this if statement is inside a while loop) folderName="Pics" if ! test -d folderName then mkdir $folderName fi However, after the folder Pics has been created, every time the... (3 Replies)
Discussion started by: trivektor
3 Replies

4. UNIX for Dummies Questions & Answers

rm: Unable to remove directory /mnt/users/test/logs/: File exists

rm: Unable to remove directory /mnt/users/test/logs/: File exists ls -latr total 191208 drwxrwxrwx 6 test echo 4096 Jul 3 22:36 .. -rwxrwxrwx 1 test echo 97692804 Jul 3 22:36 .nfsDFA4 drwxrwxr-x 2 test echo 4096 Jul 3 23:00 . M not able to delete... (4 Replies)
Discussion started by: solitare123
4 Replies

5. Shell Programming and Scripting

Test on string containing spacewhile test 1 -eq 1 do read a $a if test $a = quitC then break fi d

This is the code: while test 1 -eq 1 do read a $a if test $a = stop then break fi done I read a command on every loop an execute it. I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test. For example echo hello. Now the... (1 Reply)
Discussion started by: Max89
1 Replies

6. Shell Programming and Scripting

How to check weather a string is like test* or test* ot *test* in if condition

How to check weather a string is like test* or test* ot *test* in if condition (5 Replies)
Discussion started by: johnjerome
5 Replies

7. Shell Programming and Scripting

Test if string exists

How do I use bash to test whether a string occurs more than two times in a file? (2 Replies)
Discussion started by: locoroco
2 Replies

8. UNIX for Advanced & Expert Users

Perl XML::DOM: How to test if element exists?

Hi, I'm trying to write a script for some xml file handling, but I'm not getting too far with it. I've got the following xml content <?xml version="1.0" encoding="UTF-8"?> <Test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <Operation name="OPER1"> <Action name="ACTION1">... (2 Replies)
Discussion started by: Juha
2 Replies

9. Emergency UNIX and Linux Support

Waiting for wildcard filename to exists in while loop

Hi Experts, We are developing a script which will wait for the trigger file(with datetime in the trigger file name). But the problem is when I use 'while' loop to wait for the file, it waits for the filename with wilcard in it that is wait for 'Trigger*.done' file. :eek: Below is the script ... (4 Replies)
Discussion started by: Amey Joshi
4 Replies

10. Shell Programming and Scripting

Verify if filename exists

Hi, I have a variable returned from Oracle SQL Function which holds file names. I would like to test if all the file names mentioned in the string exists in a directory. If all the files exists print "exists", even if one file does not exists print "Does not exists". e.g. ... (3 Replies)
Discussion started by: pointers1234
3 Replies
LOOKBIB(1)						      General Commands Manual							LOOKBIB(1)

NAME
lookbib - search bibliographic databases SYNOPSIS
lookbib [ -v ] [ -istring ] [ -tn ] filename... DESCRIPTION
lookbib prints a prompt on the standard error (unless the standard input is not a terminal), reads from the standard input a line contain- ing a set of keywords, searches the bibliographic databases filename... for references containing those keywords, prints any references found on the standard output, and repeats this process until the end of input. For each database filename to be searched, if an index filename.i created by indxbib(1) exists, then it will be searched instead; each index can cover multiple databases. OPTIONS
It is possible to have whitespace between a command line option and its parameter. -v Print the version number. -istring When searching files for which no index exists, ignore the contents of fields whose names are in string. -tn Only require the first n characters of keys to be given. Initially n is 6. FILES
filename.i Index files. SEE ALSO
refer(1), lkbib(1), indxbib(1) Groff Version 1.22.2 7 February 2013 LOOKBIB(1)
All times are GMT -4. The time now is 09:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy