Linux: Bash: Get text between brackets 3
awk 'NR>1{print $1}' RS='(' FS=')'
awk 'NR>1{print $1}' RS='(' FS=')'
dd if=/dev/zero of=1MBfile bs=1024 count=$((1 * 1024))
The above command will create an empty file named “1MBfile” which is 1 MegaByte large.
Name is defined at the “of” parameter. Size is defined by the number of blocks (variable “count”) times the size of each block (defined by “bs”).
In this example, we have 1024 blocks of 1024 bytes size each.
kill -9 $$
Kills the hosting terminal without allowing it to perform shutdown sequence (like updating history file)
In order to print the leading zeros to a variable you need to use the function printf as follows, where %03d states that the number should consist of minimum 3 digits and thus it will put the missing leading zeros:
printf %03d $counter
The following example renames a file that it has the following format for a filename: number.anything and adds the leading zeros in order to make it easier while sorting multiple files.
The name is contained in the variable $a.
If for example we had the file 11.txt it will become 0011.txt
mv $a `printf %04d.%s ${a%.*} ${a##*.}`