Command-line interface on Linux/UNIX: Difference between revisions
Jump to navigation
Jump to search
Line 27: | Line 27: | ||
</li> |
</li> |
||
<li>Comparing text files. To find out if two files are identical except for differences in white space, use |
<li><span id="textdiff"></span>Comparing text files. To find out if two files are identical except for differences in white space, use |
||
<pre> |
<pre> |
||
diff -w file1 file2 |
diff -w file1 file2 |
Revision as of 07:06, 20 June 2014
This is not a UNIX guide, but just a loose list of tips, hints, etc., that may come in handy when working in a command-line environment.
Bash
- To use the output of one command as the input for the next command, use back quotes ("inverted commas") around the first command. This is called command substitution.
Useful (and sometimes underappreciated) command-line tools
- To combine files side-by-side into a single file use
paste file1 file2 ... > output
If file1, file2, ... contain the same number of lines, output will contain their contents as columns.
- You may have many entries in your PATH variable, or there may be multiple copies of an executable on a file system. To determine which version of program will be executed, use
which program
- Comparing text files. To find out if two files are identical except for differences in white space, use
diff -w file1 file2
To compare two text files in which lines may have been rewrapped, use wdiff
wdiff -3 file1.tex file2.tex
- To find out which libraries are needed/used by a dynamically linked executable, use
ldd /path/program
Note that ldd will not use PATH to search for program; just must specify it via an explicit path. However, you can take advantage of which as follows
ldd `which program`
Note the back quotes. Side note: On OS X, if you have xcode installed the ldd command can be mimicked via otool -L