Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
howtos:general_admin:cli_constructs_and_useful_info [2012/10/21 10:24 (UTC)] htexmexh [Useful commands and info] |
howtos:general_admin:cli_constructs_and_useful_info [2013/04/02 15:19 (UTC)] (current) htexmexh [Constructs] |
||
---|---|---|---|
Line 9: | Line 9: | ||
ls -1 /var/log/packages | rev | cut -d - -f 1-3 --complement | rev | ls -1 /var/log/packages | rev | cut -d - -f 1-3 --complement | rev | ||
</code> | </code> | ||
- | Or if you wanted to get the full patch of a file, minus the suffix. | + | Or if you wanted to get the full path of a file, minus the suffix. |
<code bash> | <code bash> | ||
echo /proc/config.gz | rev | cut -d. -f1 --complement | rev | echo /proc/config.gz | rev | cut -d. -f1 --complement | rev | ||
Line 97: | Line 97: | ||
bash-4.2$ | bash-4.2$ | ||
</code> | </code> | ||
- | Clearly you need to quote a file with spaces. You could use single quotes here, because no variable were inside the quotes. You should not quote in this case: | + | Clearly you need to quote a file with spaces. You could use single quotes here, because no variables were inside the quotes. You should not quote in this case: |
<code bash> | <code bash> | ||
bash-4.2$ for i in $(seq 1 10); do printf "$i "; done; echo; | bash-4.2$ for i in $(seq 1 10); do printf "$i "; done; echo; | ||
Line 148: | Line 148: | ||
=== External Links === | === External Links === | ||
* http://www.grymoire.com/Unix/Quote.html | * http://www.grymoire.com/Unix/Quote.html | ||
- | ==== Regex ==== | + | ==== Regular expressions ==== |
=== Basic === | === Basic === | ||
* ''.'' matches any single character. | * ''.'' matches any single character. | ||
Line 174: | Line 174: | ||
* Example: ''\<[tT]he\>'' matches the word ''the'' or ''The''. | * Example: ''\<[tT]he\>'' matches the word ''the'' or ''The''. | ||
* ''*'' matches any number of the previous character or nothing = no character. Example: ''[0-9]*'' which will match any number of numbers. ''.*'' matches any number of anything. | * ''*'' matches any number of the previous character or nothing = no character. Example: ''[0-9]*'' which will match any number of numbers. ''.*'' matches any number of anything. | ||
- | === Extended === | + | === Extended regular expressions === |
The following must be supported by the program for them to work. For example for grep you must run ''egrep'' or ''grep -E''. | The following must be supported by the program for them to work. For example for grep you must run ''egrep'' or ''grep -E''. | ||
* ''+'' matches any number of the previous character, like ''*'', but there must be at least one to match, so it will not match nothing or no character. | * ''+'' matches any number of the previous character, like ''*'', but there must be at least one to match, so it will not match nothing or no character. | ||
Line 203: | Line 203: | ||
du -s directory | du -s directory | ||
</code> | </code> | ||
+ | === cmp === | ||
+ | This can compare two files byte by byte, and can be more useful than checksums. For example, after you burn a CD/DVD, you can run: | ||
+ | <code bash> | ||
+ | cmp slackware.iso /dev/sr0 | ||
+ | </code> | ||
+ | It should say the following if the disk burned correctly: | ||
+ | <code bash> | ||
+ | cmp: EOF on slackware.iso | ||
+ | </code> | ||
+ | === shell math === | ||
+ | Remember that shell utilities like ''let'' and ''expr'' only do integer math. For floating point use either ''bc'' or ''awk''. | ||
+ | === shell GUI === | ||
+ | There are numerous programs that allow you to create GUIs from a shell script. | ||
+ | * [[http://xdialog.free.fr/|Xdialog is fully dialog compatible.]] | ||
+ | * [[https://sites.google.com/site/easybashgui/home|A function library that increases shell GUI portability.]] | ||
+ | * [[http://code.google.com/p/gtkdialog/|Gtkdialog has advanced features for customized GUIs.]] | ||
=== External Links === | === External Links === | ||
* [[http://www.grymoire.com/Unix/|Guide to awk, bash, sed, find, and more]] | * [[http://www.grymoire.com/Unix/|Guide to awk, bash, sed, find, and more]] | ||
Line 216: | Line 232: | ||
* I quoted ''man comm'' | * I quoted ''man comm'' | ||
* I used ''man grep'' for the regex section. | * I used ''man grep'' for the regex section. | ||
+ | * Written by [[wiki:user:htexmexh|H_TeXMeX_H]] | ||
<!-- Please do not modify anything below, except adding new tags.--> | <!-- Please do not modify anything below, except adding new tags.--> | ||
<!-- You must remove the tag-word "template" below before saving your new page --> | <!-- You must remove the tag-word "template" below before saving your new page --> | ||
- | {{tag>howtos software author_htexmexh work_in_progress}} | + | {{tag>howtos software author_htexmexh}} |