Forcing the order of output fields from cut command

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

How can I extract the first two characters of a string in shell scripting?

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

How do I read the source code of shell commands?

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)