Set default editor
We can set this variable in the
chmod Numerical permissions
|7||read, write, and execute|
|6||read and write|
|5||read and execute|
|3||write and execute|
A permission have 3 numbers: owner, group and anyone else. An example,
stands for; the owner can read, write and execute, group and anyone else can
read only the file.
Append Current Date To Filename in Bash Shell
To get the current date in mm_dd_yyyy format use the following date format syntax:
You can store this to a variable name:
Finally, you can create a filename as follows:
now=$(date +"%m_%d_%Y") echo "Filename : /nas/backup_$now.sql"
You can create a shell script as follows:
#!/bin/bash _now=$(date +"%m_%d_%Y") _file="/nas/backup_$_now.sql" echo "Starting backup to $_file..." # mysqldump -u admin -p'myPasswordHere' myDbNameHere > "$_file"
How can I delete duplicate lines in a file in Unix?
$ awk '!seen[$0]++' file.txt
seen is an associative-array that Awk will pass every line of the file to. If a line isn’t in the array then
seen[$0] will evaluate to false. The
! is a logical NOT operator and will invert the false to true. Awk will print the lines where the expression evaluates to true. The
++ increments seen so that
seen[$0] == 1 after the first time a line is found and then
seen[$0] == 2, and so on.
Awk evaluates everything but
"" (empty string) to true. If a duplicate line is placed in seen then
!seen[$0] will evaluate to false and the line will not be written to the output
How to check spelling at the Linux command line with Aspell
To check the spelling of a file, just type:
$ aspell check file.txt
How to use unicode characters in Windows command line?
In powershell type:
It will change the code page to UTF-8. Also, you need to use Lucida console fonts.
(I use this to build a hakyll project on Windows)
Another answer at Windows 10 terminal encoding.
$ tar -czf filename.tar.gz file-1 [file-2 file-3 ...] # creates a tar.gz o tgz file $ tar -ztvf filename.tar.gz # list the content of a tar.gz or .tgz file $ tar -xzf filename.tar.gz # extract the content of a tar.gz or .tgz file
How do I scroll in tmux?
[ then you can use your normal navigation keys to scroll around (eg.
Up Arrow or
q to quit scroll mode.