How to test for if two files exist?
Try adding an additional square bracket.
if [[ -f .ssh/id_rsa && -f .ssh/id_rsa.pub ]]; then
Execute a Command if Two Files Exist
You need to separate the tests into their own square brackets:
if [ -e file ] && [ -e file ]; then
echo "wow"
fi
How to check if two files exist
Try this:
You need to check the file existence separately.
if (file_exists($admin) && file_exists($catalog)) {
$route['default_controller'] = "upgrade/index";
$route['404_override'] = '';
} else {
$route['default_controller'] = "step_1/index";
$route['404_override'] = '';
}
You can read on the manual, file_exists.
How to test if multiple files exist using a Bash script
To avoid "too many arguments error", you need xargs
. Unfortunately, test -f
doesn't support multiple files. The following one-liner should work:
for i in /var/log/apache2/access.log.*; do test -f "$i" && echo "exists one or more files" && break; done
By the way, /var/log/apache2/access.log.*
is called shell-globbing, not regexp. Please see Confusion with shell-globbing wildcards and Regex for more information.
Check if two files exist, then if they do, run batch file
check the first, then the next, if the first does not match, it will not attempt the second, if it does it will attempt the second but not run the command if second file not found:
if exist "c:\file1.txt" if exist "c:\file2.txt" msiexec /I "\SERVER...\application.msi"
Check whether two files exist (in shell script)
if [ -e File1Name -a -e File2Name ]
then
echo Yes
else
echo No
fi
Check if the two Files exist in the folder
Like this?
string path = @"";
DirectoryInfo dir = new DirectoryInfo(path);
var files = dir.GetFiles("*.txt");
if (files.Length >= 2)
{
}
How to check two file exist in same folder?
Do this
File yourDir = new File(Environment.getExternalStorageDirectory(), "Testapp");
for (File f : yourDir.listFiles()) {
if (f.isFile()){
String name = f.getName();
if(name.equals("music1.mp3")) {
// music1.mp3 present
} else if(name.equals("music2.mp3")) {
// music2.mp3 present
}
}
}
More efficient way as suggested by @Henry below in comments
File file1 = new File(Environment.getExternalStorageDirectory()+"/Testapp/music1.mp3");
File file2 = new File(Environment.getExternalStorageDirectory()+"/Testapp/music2.mp3");
if (file1.exists()) {
// music1.mp3 present
} else if (file2.exists()) {
// music2.mp3 present
}
Regex to check if multiple files exist using one if then statement
What you're trying to do isn't working because you're trying to do two checks in one.
Try changing this line
if [ -s ${PREFIX}_R[1,2].fastq ]
to this
if [ -s ${PREFIX}_R1.fastq ] && [ -s ${PREFIX}_R2.fastq ]; then
Related Topics
Fast Way to Get Image Dimensions (Not Filesize)
How to Shield a CPU from the Linux Scheduler (Prevent It Scheduling Threads Onto That Cpu)
Difference Between Vm.Dirty_Ratio and Vm.Dirty_Background_Ratio
How to Know Which of the /Dev/Input/Eventx (X=0..7) Have the Linux Input Stream
Check Battery Level of Connected Bluetooth Device on Linux
Find Files in Created Between a Date Range
Best Practices for Git Repositories on Open Source Projects
I Want to Contribute to the Linux Kernel
Preserve Colouring After Piping Grep to Grep
Installing Node.Js on Debian 6.0
How to Learn the Structure of Linux Wireless Drivers (Mac80211)
Linux Free Shows High Memory Usage But Top Does Not
How to Hide Wget Output in Linux
Home/End Keys Do Not Work in Tmux
"Git Add" Returning "Fatal: Outside Repository" Error
Git Forces Refresh Index After Switching Between Windows and Linux