Sponsored Content
Full Discussion: check for FILES existence
Top Forums Shell Programming and Scripting check for FILES existence Post 302078088 by blowtorch on Wednesday 28th of June 2006 12:21:21 AM
Old 06-28-2006
You can avoid using the ls command here. Also, mbketan, using '-f' is perhaps better that using '-s' in this case, as the OP may also want to test for empty (zero byte) files.
Code:
#!/usr/bin/ksh
for file in *; do
[[ -f $file ]] && echo $file is a regular file
done

Wait a minute, it seems that the OP wants to test for a list of filenames that (s)he already has. In that case, do this:
Code:
#!/usr/bin/ksh
for file in $@; do
[[ -f $file ]] && echo $file exists
done


Last edited by blowtorch; 06-28-2006 at 01:28 AM..
 

10 More Discussions You Might Find Interesting

1. AIX

check for file existence

Hello I am having a requirement like if there is no file in the directory then i need a message to pop on after the execution of the script. My script basically does for File in `ls -t $DIRECTORY | tail -1`; if there is no file the DIRECTORY then the script is simply exiting with out... (2 Replies)
Discussion started by: dsdev_123
2 Replies

2. AIX

Check for File Existence

I have requirement where i need to search for files which start with SALESORDER and PURCHASEORDER. i need to process the files with SALESORDER first and then PURCHASEORDER. If SALESORDER files are not there i dont want to process PURCHASEORDER and i want to come out of script. I have written a code... (4 Replies)
Discussion started by: dsdev_123
4 Replies

3. Shell Programming and Scripting

How to check for file existence?

i want to check if the file is in the directory or not, and also it should be handle error conditions, like missing files and report the error and exit. i did something like this: file ="hello" if !test -e "${file}" then echo "No such files exist!" exit 1 else do something....... fi ... (1 Reply)
Discussion started by: mingming88
1 Replies

4. Shell Programming and Scripting

Check existence of a number of files and call other scripts

Hi, I am new to unix scripting and am jus getting to learn about it.. I need to know on how to check for the existence of a number of files in a path..i.e the files are ftp'ed from several other servers, should check if all the files have arrived, if not wait till they arrive..can i use a flag... (5 Replies)
Discussion started by: yohasini
5 Replies

5. UNIX for Dummies Questions & Answers

To check for existence of a file

I need to check for the existence of a file *.log in a specific directory using a perl script. Presently am not in that particular directory. So i am using chdir ("/path/to/my/file) And then i am using the -e in an if statement to check if it exists. if (-e $File) {......} $File contains the... (1 Reply)
Discussion started by: manutd
1 Replies

6. Shell Programming and Scripting

check existence of files in a folder

Hi I am having a problem to verify existence of files. I need to know whether or not files in a folder that begins with a name. For example all files that start with The_File_ *. I was doing it this way, but gives me error. if text -f /work/The_File_* then ... else .. fi (5 Replies)
Discussion started by: Rodrih92
5 Replies

7. Shell Programming and Scripting

Check for the existence and add them from 2 different files

Hi, I have two files file1: ALEX DANY GARY TOM MARY HARRIS file2: ALEX 3 ALEX 5 ALEX 0 ALEX 1 ALEX 0 DANY 2 (2 Replies)
Discussion started by: Diya123
2 Replies

8. Shell Programming and Scripting

Check the Files existence

Hi I have a requirement to check whether the files exists, then it will call other steps in shell script. I did ls *.csv|wc -l if then checking the count of the files should be more than 1 then it will call other steps. I am getting the error that too many arguements as there n... (13 Replies)
Discussion started by: cnrj
13 Replies

9. Shell Programming and Scripting

File existence check

hi i wanted to check if the file exist or not(multiple files) DIRE=/home/V478 if ; then echo "file present" else echo "file not present" fi But i am getting the error as : [: unexpected operator/operand (3 Replies)
Discussion started by: ATWC
3 Replies

10. Shell Programming and Scripting

Script to check the files existence inside a directory.

Hello Folks, On Below Script, I want to apply condition. Condition that it check the directory for files if not found keep checking. Once directory have files and founded do the calculation and finish the code. Script to check the files existence inside a directory, If not then keep... (16 Replies)
Discussion started by: sadique.manzar
16 Replies
pwck(8) 						      System Manager's Manual							   pwck(8)

NAME
pwck, grpck - Checks the password and group files for inconsistencies SYNOPSIS
pwck [-admNs] [file] grpck [-mNp] [file] FLAGS
Causes both pwck and grpck to additionally check the NIS database entries using the same consistency tests. Users that are defined in the local password or group file without the "+" at the start of the name field are flagged as duplicate entries. pwck Inhibits the running of the /tcb/bin/authck -p command on a system running Enhanced Security. Prevents pwck from checking for the presence of the user's login directory. Directs pwck to check for mixed case usernames. Causes pwck to check for the presence of the optional shell field for each entry. grck If there are no members, causes grpck to display a message indicating the listed group has no members. Directs grpck to not check for a users' existence in the password database (local or NIS). DESCRIPTION
The pwck command scans the /etc/passwd file, or the named file, and writes to standard out any inconsistencies. The scan checks the number of fields, login name, user ID, group ID, and existence of a login directory and optional program name. The grpck command scans the /etc/group file, or the named file, and writes to standard out any inconsistencies. The scan checks the number of fields, group name, group ID, and whether all login names appear in the password file. EXAMPLES
To verify the password information in the /etc/passwd file for consistency, enter: pwck To verify the password information in the /etc/passwd file and the NIS database for consistency without checking each users login directory validity, enter: pwck -Nd To verify the group information in the /etc/group file and the NIS database for consistency, enter: grpck -N FILES
Specifies the command path Specifies the command path Contains user information Contains group information RELATED INFORMATION
Commands: adduser(8), authck(8), groups(1), passwd(1), vipw(8) Files: passwd(4), group(4), ypfiles(4) delim off pwck(8)
All times are GMT -4. The time now is 12:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy