This KB explains the steps on how to delete a file named with a special character in a directory in Junos shell
In the below example, /var is running low on space.
root@user:RE:0% df -hFilesystem Size Used Avail Capacity Mounted on/dev/da0s3e 170M 157M -1.1M 101% /varUsing the below KB we can determine which directory and file is the culprit.https://supportportal.juniper.net/s/article/EX-QFX-How-to-troubleshoot-var-partition-usage-is-highIn below eg, /var/home/superuser directory has a file named "~" using up all the space.
root@lab:RE:0% cd /var/home/superuser/
root@lab:RE:0% ls -lrttotal 291480-rw-r--r-- 1 superuser 20 3761 Dec 4 2018 h-rw-r--r-- 1 superuser 20 4043 May 16 2019 how configuration policy-options prefix-list SNMP-RE-FILTER 10.144.104.55-rw-r--r-- 1 superuser 20 4043 May 16 2019 et snmp trap-options source-address lo0-rw-r--r-- 1 superuser 20 149127168 Mar 12 20:19 ~-rw-r--r-- 1 superuser 20 0 Mar 12 20:31 [email protected]drwx------ 2 superuser 20 512 Mar 15 20:10 .ssh-rw-r--r-- 1 superuser 20 30720 Mar 29 18:59 janus16-03-29-2024-config-backup.tgzIf we check that file with regular file command, it will show up as symbolic link to /root
root@lab:RE:0% file ~/root: symbolic link to `/var/root'
Hence to delete such files which have special characters as their name, use character "\" before the file name to identify it as a file and its type and NOT as a symlink.
For eg:root@lab:RE:0% file \~~: gzip compressed data, from Unix ===============> using \ before ~ gives the file type
root@lab:RE:0% rm \~
Now the file named "~" has been safely deleted hence freeing up the space.
root@uer103:RE:0% ls -lrttotal 88-rw-r--r-- 1 superuser 20 3761 Dec 4 2018 h-rw-r--r-- 1 superuser 20 4043 May 16 2019 how configuration policy-options prefix-list SNMP-RE-FILTER 10.144.104.55-rw-r--r-- 1 superuser 20 4043 May 16 2019 et snmp trap-options source-address lo0-rw-r--r-- 1 superuser 20 0 Mar 12 20:31 [email protected]drwx------ 2 superuser 20 512 Mar 15 20:10 .ssh-rw-r--r-- 1 superuser 20 30720 Mar 29 18:59 janus16-03-29-2024-config-backup.tgz
root@uer103:RE:0% df -ih /var/Filesystem Size Used Avail Capacity iused ifree %iused Mounted on/dev/da0s3e 170M 15M 141M 10% 765 21761 3% /var