Questions tagged [test-command]

`test` is a unix command to check file types and compare values.

test is a unix command to check file types and compare values.

Its information can be found by checking man test.

5 questions
2
votes
3 answers

Bash: test (builtin) with several arguments: how are they parsed?

I have not used this particular construct for the bash builtin test / [ commands, but I ran into it today and I'm confused. It looks like this: [ -n "${FOO}" -a -r ${FOO}/bar ] && echo OK I know what each switch does individually, but I am not sure…
Z4-tier
  • 7,287
  • 3
  • 26
  • 42
2
votes
1 answer

Passing pipe output to Test command

I'm confused with test command syntax. My goal is to check if file exists, but file path formed by sed command. So, I try, for example: echo '~/test111' | sed s/111/222/g | test -f && echo "found" || echo "not found" But that command always returns…
user3414386
2
votes
2 answers

see if a directory/file exists with spaces in the name

I want ot check if a path is a file or a directory. I know the path exists. The code below works as long as no spaces are in the path. How to make this work for names with spaces? I currently have a file with a name in it and cannot check if it…
Rafael Urena
  • 111
  • 2
  • 3
0
votes
1 answer

How to use uboot test command 'or' -o option

From the output below it appears that the command does not work with integers, or the true and false commands, so what is the intended use of test -o (or) command? => version U-Boot 2017.01 (Apr 01 2021 - 00:00:00 +0000) arm-poky-linux-gnueabi-gcc…
Buoy
  • 307
  • 1
  • 9
0
votes
2 answers

Behaviour of "-s" option with "test" command in bash script

The code is: src=/home/Desktop/src dest=/home/Desktop/dest if test -s $src/$InputFile ; then echo "File is present. :$InputFile" else echo "File is not present" fi In the above code if I declare variable "InputFile" as InputFile=a.txt then…
ziga
  • 109
  • 10