This article provides information about the useful Unix commands that can be used in the router/svl-jtac-tool shell during troubleshooting and normal operations.
Information about the useful Unix commands that can be used in the router/svl-jtac-tool shell during troubleshooting and normal operations.
Customized search in different locations:
- . current directory
- / whole system
- ~ Home directory
To list all the files whose file size is bigger than 4096 bytes, use the following command:
root@mx480-6% find . -type f -size +4096c
To list all the files whose file size is smaller than 4096 bytes, use the following command:
root@mx480-6% find . -type f -size -4096c
To list all the file names whose file size is greater than 512bytes and owner is lab (check this in the router), use the following command:
root@mx480-6% ls -al | awk '$3 == "lab" && $5 > 512 {print $9}'
To list all file names whose file size is greater than 512bytes and owner is rengar (check this in the server), use the following command:
> ls -al | awk '$3 == "rengar" && $5 > 512 {PRINT.EN_US}'
To calculate the total size of a directory in Mb, use the following command:
> ls -al | awk '{total +=$5};END {print "Total size: "total/1024/1024 " Mb"}'
To calculate the total size of a directory, including sub directories, in Mb, use the following command:
> ls -lR | awk '{total +=$5};END {print "Total size: "total/1024/1024 " Mb"}'
To identify the largest file in a directory, including sub directories, use the following command:
root@mx480-6% ls -lR |awk '{print $5 "\t" $9}' |sort -n |tail -1
To delete leading whitespace (spaces, tabs) from the beginning of each line, use the following command:
root@mx480-6% sed 's/^[ \t]*//' file-name
To delete trailing whitespace (spaces, tabs) from the end of each line, use the following command:
root@mx480-6% sed 's/[ \t]*$//' filename
To delete both leading and trailing whitespaces from each line, use the following command:
root@mx480-6% sed 's/^[ \t]*//;s/[ \t]*$//' file-name
To delete all blank lines from a file, use the following command:
root@mx480-6% sed '/^$/d' file-name
To clear the terminal screen, use the following commands:
$ CTRL+l $ reset