command line - bash: existing file not existing - or existing? or not? - Ask Ubuntu
i have issue, can't fix, , hope, here.
in directory named qemu-servers should file named 100.conf. but, bash not show it, if test it, it's there...
root@proxmox:/etc/pve/nodes/proxmox/qemu-server# test 100.conf && echo "found" || echo "not found" found if ls -a it's not shown:
root@proxmox:/etc/pve/nodes/proxmox/qemu-server# ls -a . .. 101.conf there file named 101.conf, not 100.conf
if try rm 100.conf, touch or else, bash gives error:
root@proxmox:/etc/pve/nodes/proxmox/qemu-server# rm 100.conf rm: cannot remove ‘100.conf’: no such file or directory root@proxmox:/etc/pve/nodes/proxmox/qemu-server# touch 100.conf touch: cannot touch ‘100.conf’: file exists how can rid of problem?
the problem here:
test 100.conf it doing string test i.e. if string 100.conf not empty. not empty, you'll found.
this analogous to:
test -n 100.conf [ 100.conf ] [ -n 100.conf ] you need file existence check i.e. test -f:
test -f 100.conf && echo "found" || echo "not found"
Comments
Post a Comment