Sponsored Content
Full Discussion: For or while?
Top Forums Shell Programming and Scripting For or while? Post 302972351 by Don Cragun on Wednesday 4th of May 2016 09:17:50 AM
Old 05-04-2016
Why isn't the diagnostic output from ls sufficient to let you know that a file doesn't exist? If for some reason, you do need to test for a file's existence (without caring what its size is):
Code:
#!/bin/ksh
while read -r file
do	if [ -e "$file" ]
	then	printf 'file "%s" exists.\n' "$file"
		ls -lrt "$file"
	else	printf 'file "%s" does not exist.\n" "$file"
	fi
done < files.txt

 
All times are GMT -4. The time now is 05:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy