User Tools

Site Tools


files-and-directories

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
files-and-directories [2020/03/24 16:50]
Miroslav Bernát
files-and-directories [2020/05/15 12:26] (current)
Miroslav Bernát
Line 35: Line 35:
 ^ The Contents of a File ^ ^ ^ The Contents of a File ^ ^
 | **file** <​file>​ | determines file data type (ASCII, PDF, HTML etc.), **-z** the contents of the compressed file\\ ''​$ file * | grep ASCII''​ | | **file** <​file>​ | determines file data type (ASCII, PDF, HTML etc.), **-z** the contents of the compressed file\\ ''​$ file * | grep ASCII''​ |
-| **od** (<​file>​) | (**-o**) prints the contents of a binary file in octal format, **-d** in decimal format, **-x** in hexadecimal format, **-j** <​byte>​ prints data from the specified byte (offset), **-w**<​number_of_bytes>​ displays the specified number of bytes on one line; the first column of the output represents an offset – the sequence of the first byte of the particular line from the beginning of the file; if no file is specified, reads from STDIN\\ ''​$ od -w8 /​usr/​bin/​who''​\\ ''​$ od -j 0474360 /​usr/​bin/​find''​ | 
-| **strings** <​file>​ | prints text strings contained especially inside a binary file with a minimum length of four characters\\ ''#​ strings $(which vsftpd) | egrep "​libwrap|hosts"''​\\ (checks if the program is related to tcp wrappers) | 
 | **cat** (<​file>​) | prints the contents of a text file, **-n** numbers all lines, **-b** numbers lines containing a text; if no file is specified, reads from STDIN\\ ''​$ cat a b c  > abc''​ | | **cat** (<​file>​) | prints the contents of a text file, **-n** numbers all lines, **-b** numbers lines containing a text; if no file is specified, reads from STDIN\\ ''​$ cat a b c  > abc''​ |
 | **tac** (<​file>​) | prints the contents of a text file in reverse; if no file is specified, reads from STDIN | | **tac** (<​file>​) | prints the contents of a text file in reverse; if no file is specified, reads from STDIN |
Line 68: Line 66:
 | **convmv** <​file/​directory>​ | changes the type of coding of a file/​directory name, **-f** <​source_code>​ defines the original code, **-t** <​target_code>​ defines a new code, **-i** interactive mode, **-r** recursively,​ **--notest** ensures real recoding of a file name\\ ''​$ convmv --notest -f cp1250 -t UTF-8 *''​ | | **convmv** <​file/​directory>​ | changes the type of coding of a file/​directory name, **-f** <​source_code>​ defines the original code, **-t** <​target_code>​ defines a new code, **-i** interactive mode, **-r** recursively,​ **--notest** ensures real recoding of a file name\\ ''​$ convmv --notest -f cp1250 -t UTF-8 *''​ |
 | **recode** <​source_code>​**..**<​target_code>​ <​file>​ | changes the type of coding of a text file, **-l** prints types of coding, **-f** suppresses error output, **-v** detailed output\\ ''​$ echo 'List of all file names' | recode -f UTF-8..flat''​\\ ''​$ recode ..HTML < page.txt > page.html''​\\ ''​$ find . -name "​*.txt"​ -exec recode cp1250..UTF-8 '​{}'​ \;''​ | | **recode** <​source_code>​**..**<​target_code>​ <​file>​ | changes the type of coding of a text file, **-l** prints types of coding, **-f** suppresses error output, **-v** detailed output\\ ''​$ echo 'List of all file names' | recode -f UTF-8..flat''​\\ ''​$ recode ..HTML < page.txt > page.html''​\\ ''​$ find . -name "​*.txt"​ -exec recode cp1250..UTF-8 '​{}'​ \;''​ |
 +| **od** (<​file>​) | (**-o**) prints the contents of a binary file in octal format, **-d** in decimal format, **-x** in hexadecimal format, **-j** <​byte>​ prints data from the specified byte (offset), **-w**<​number_of_bytes>​ displays the specified number of bytes on one line; the first column of the output represents an offset – the sequence of the first byte of the particular line from the beginning of the file; if no file is specified, reads from STDIN\\ ''​$ od -w8 /​usr/​bin/​who''​\\ ''​$ od -j 0474360 /​usr/​bin/​find''​ |
 +| **strings** <​file>​ | prints text strings contained especially inside a binary file with a minimum length of four characters\\ ''#​ strings $(which vsftpd) | egrep "​libwrap|hosts"''​\\ (checks if the program is related to tcp wrappers) |
 +| **msgfmt** <​file>​.po | converts a text file to a binary format, **-o** <​file>​.mo specifies the output file\\ ''​$ msgfmt -o woocommerce-cs_CZ.mo woocommerce-cs_CZ.po''​ |
 | **convert** <​source>​ <​target>​ | changes file formats and possibly their sizes\\ ''​$ convert image.tif image.jpg''​\\ ''​$ IFS=',';​ cmds="​hostname -s,​date,​ifconfig -a"; for cmd in $cmds; do { echo "​[$USER@${HOSTNAME} ${PWD/#​$HOME/​~}]"​ "​${cmd}";​};​ eval "​${cmd}";​ done > info.txt && convert -background black -fill white info.txt info.png''​\\ (creates a printscreen of the terminal with the specified commands) | | **convert** <​source>​ <​target>​ | changes file formats and possibly their sizes\\ ''​$ convert image.tif image.jpg''​\\ ''​$ IFS=',';​ cmds="​hostname -s,​date,​ifconfig -a"; for cmd in $cmds; do { echo "​[$USER@${HOSTNAME} ${PWD/#​$HOME/​~}]"​ "​${cmd}";​};​ eval "​${cmd}";​ done > info.txt && convert -background black -fill white info.txt info.png''​\\ (creates a printscreen of the terminal with the specified commands) |
 | **aplay** <​file>​ | plays a specified audio file | | **aplay** <​file>​ | plays a specified audio file |