commandline session [bash light=”true”] $echo improve > clean.txt $cat clean.txt improve $set -o noclobber $echo new > clean.txt bash: clean.txt: cannot overwrite existing file $echo new >> clean.txt $cat clean.txt improve new $echo again >| clean.txt $cat clean.txt again $set +o noclobber $echo improve > clean.txt $cat clean.txt improve $ [/bash]
Category Archives: Bash
pstree command in linux I
Commandline Session $pstree -pA init(1)-+-/usr/sbin/apach(2306)-+-/usr/sbin/apach(4451) | |-/usr/sbin/apach(4452) | |-/usr/sbin/apach(4453) | |-/usr/sbin/apach(4454) | `-/usr/sbin/apach(4455) |-NetworkManager(2145)-+-dhclient(4539) | |-{NetworkManager}(2196) | `-{NetworkManager}(4540) |-accounts-daemon(2233)—{accounts-daemon}(2235) |-at-spi-bus-laun(3756)-+-dbus-daemon(3761) | |-{at-spi-bus-laun}(3758) | |-{at-spi-bus-laun}(3760) | `-{at-spi-bus-laun}(3762) |-at-spi2-registr(3764)—{at-spi2-registr}(37100) |-atd(2334) |-atop(2361) |-avahi-daemon(2372)—avahi-daemon(2373) |-bluetoothd(2399) |-colord(3919)—{colord}(3928) |-colord-sane(3931)-+-{colord-sane}(3935) | `-{colord-sane}(4015) |-console-kit-dae(2237)-+-{console-kit-dae}(2238) | |-{console-kit-dae}(2239) | |-{console-kit-dae}(2240) | |-{console-kit-dae}(2241) | |-{console-kit-dae}(2242) | |-{console-kit-dae}(2243) | |-{console-kit-dae}(2244) | |-{console-kit-dae}(2245) | |-{console-kit-dae}(2246) | |-{console-kit-dae}(2247) | …
How does && and || operators combination Work ?
commandline session $ 4.2.29 10 510—> [ -f wordmatc.c ] || echo hello hello $ 4.2.29 11 511—> [ -f wordmatc.c ] || cat baty && echo hello cat: baty: No such file or directory $ 4.2.29 12 512—> [ -f wordmatc.c ] && echo hello || echo kitten kitten $ 4.2.29 13 513—> [ …
Continue reading “How does && and || operators combination Work ?”
coproc is a shell keyword related to coprocesses in GNU Bash
ABOUT coproc Bash 4.0 introduced coprocesses, a feature certainly familiar to ksh users. The coproc keyword starts a command as a background job, setting up pipes connected to both its stdin and stdout so that you can interact with it bidirectionally. Optionally, the co-process can have a name NAME. If NAME is given, the command …
Continue reading “coproc is a shell keyword related to coprocesses in GNU Bash”
How does bracket expression and negation [^ ] work with grep ?
commandline session $ 4.2.20 19 519—> grep ‘[^b ]sort’ worked Heapsort Quicksort Timsort $ 4.2.20 20 520—> cat worked Bubble sort Selection sort Insertion sort Shell sort Comb sort Merge sort Heapsort Quicksort Counting sort Bucket sort Radix sort Distribution sort Timsort $ 4.2.20 21 521—>
id – print real and effective user and group IDs
A UNIX Command $id uid=1000(jeffrin) gid=1000(jeffrin) groups=1000(jeffrin),29(audio),1001(wireshark) $id -n id: cannot print only names or real IDs in default format $id -a uid=1000(jeffrin) gid=1000(jeffrin) groups=1000(jeffrin),29(audio),1001(wireshark) $id -g 1000 $id -G 1000 29 1001 $id -Gn jeffrin audio wireshark $id -r id: cannot print only names or real IDs in default format $id -rG 1000 29 …
Continue reading “id – print real and effective user and group IDs”
number of processing units.
$nproc 1 $nproc –all 1 $ nproc Print the number of processing units available to the current process, which may be less than the number of online processors