Showing posts with label BASH. Show all posts
Showing posts with label BASH. Show all posts

How to empty file without delete/recreate or VI

This is simpler way to empty a file in bash, few options for you to choose:

Option 1:
bash# cat /dev/null > [filename]

Option 2:
bash# > [filename]

Option 3:
bash# echo -n > [filename]

Option 4:
bash# cat > [filename]
and then Press Ctrl -D

BASH: unary operator expected

Well, this is a very good reference if you face that error in your bash script:

http://linuxcommand.org/wss0100.php