Where can I find the source code of Unix utilities? [closed]
On Debian and Ubuntu: apt-get source coreutils More generally: http://ftp.gnu.org/gnu/coreutils/
On Debian and Ubuntu: apt-get source coreutils More generally: http://ftp.gnu.org/gnu/coreutils/
This can’t be done using cut. According to the man page: Selected input is written in the same order that it is read, and is written exactly once. Patching cut has been proposed many times, but even complete patches have been rejected. Instead, you can do it using awk, like this: awk ‘{print($2,”\t”,$1)}’ abcd.txt Replace … Read more
You can use pr to do this, using the -m flag to merge the files, one per column, and -t to omit headers, eg. pr -m -t one.txt two.txt outputs: apple The quick brown fox.. pear foo longer line than the last two bar last line linux skipped a line See Also: Print command result … Read more
Probably the most efficient method, if you’re using the bash shell (and you appear to be, based on your comments), is to use the sub-string variant of parameter expansion: pax> long=”USCAGol.blah.blah.blah” pax> short=”${long:0:2}” ; echo “${short}” US This will set short to be the first two characters of long. If long is shorter than two … Read more
All these basic commands are part of the coreutils package. You can find all information you need here: http://www.gnu.org/software/coreutils/ If you want to download the latest source, you should use git: git clone git://git.sv.gnu.org/coreutils To install git on your Ubuntu machine, you should use apt-get (git is not included in the standard Ubuntu installation): sudo … Read more
You can also use parameter expansion: $ filename=foo.txt $ echo “${filename%.*}” foo Just be aware that if there is no file extension, it will look further back for dots, e.g. If the filename only starts with a dot (e.g. .bashrc) it will remove the whole filename. If there’s a dot only in the path (e.g. … Read more