sed – stream editor for filtering and transforming text

commandline session

$ 4.2.20 36 535---> cat tiles.txt
1.
width 2 meters and 15 centimeters
height 1 meters and 50 centimeters

area =  2.15 * 1.50 = 3.225  square meter


2.

width 2 meters and 15 centimeters
height 43 centimeters

area = .9245 square meter


Sum = 4.1495 square meter.


1 tile =  .1350 square meter


approximatley 40 tiles related.

1800 rupees related
$ 4.2.20 37 536---> sed  s/related/connected/g tiles.txt
1.
width 2 meters and 15 centimeters
height 1 meters and 50 centimeters

area =  2.15 * 1.50 = 3.225  square meter


2.

width 2 meters and 15 centimeters
height 43 centimeters

area = .9245 square meter


Sum = 4.1495 square meter.


1 tile =  .1350 square meter


approximatley 40 tiles connected.

1800 rupees connected
$ 4.2.20 38 537--->

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 that follows must be a compound command. If no NAME is given, then the command can be either simple or compound.

The process ID of the shell spawned to execute the coprocess is available through the value of the variable named by NAME followed by a _PID suffix. For example, the variable name used to store the PID of a coproc started with no NAME given would be COPROC_PID (because COPROC is the default NAME). The wait builtin command may be used to wait for the coprocess to terminate. Additionally, coprocesses may be manipulated through their jobspec

[bash]
$coproc ls
[1] 4620
$coproc ls
bash: warning: execute_coproc: coproc [4620:COPROC] still exists
[2] 4621
[1] Done coproc COPROC ls
$coproc top
bash: warning: execute_coproc: coproc [4621:COPROC] still exists
[3] 4622
[2] Done coproc COPROC ls
$top: failed tty get

[3]+ Exit 1 coproc COPROC top
$coproc date
[1] 4624
$coproc arch
bash: warning: execute_coproc: coproc [4624:COPROC] still exists
[2] 4625
[1] Done coproc COPROC date
$coproc arch
bash: warning: execute_coproc: coproc [4625:COPROC] still exists
[3] 4628
[2] Done coproc COPROC arch
$fg 1
bash: fg: 1: no such job
[3]+ Done coproc COPROC arch
$
[/bash]
LINKS
https://wiki-dev.bash-hackers.org/syntax/keywords/coproc
http://blog.amit-agarwal.co.in/2010/05/10/coproc-feature-bash/

accident in experiments : ls !a and ls ?a

accident in experiments

$ 4.2.20 8 507---> cat .bashrc
#export PS1="[ 33[0;31m] $ V # ! "
export PS1="$ V # !---> "

shellp()
{
pre=: post=:
printf "$pre%s$postn" "$@"
}

$ 4.2.20 9 508---> shopt -u extglob
accident fixme
$ 4.2.20 10 509---> ls ?a
NetworkSystemAdministration.pdf
$ 4.2.20 26 525---> pwd
/home/jeffrin
$ 4.2.20 27 526---> cd sa
$ 4.2.20 28 527---> pwd
/home/jeffrin/sa
$ 4.2.20 29 528---> ls
NetworkSystemAdministration.pdf
$ 4.2.20 30 529---> ls ?a
ls: cannot access ?a: No such file or directory
$ 4.2.20 31 530---> cd ..
$ 4.2.20 32 531---> pwd
/home/jeffrin
$ 4.2.20 33 532---> ls ?a
NetworkSystemAdministration.pdf
$ 4.2.20 34 533--->

$ 4.2.20 11 510---> ls ?b
bb
$ 4.2.20 12 511---> ls ?c
ls: cannot access ?c: No such file or directory
$ 4.2.20 13 512---> ls ?t
rt
$ 4.2.20 14 513---> ls ?a
NetworkSystemAdministration.pdf
$ 4.2.20 15 514---> shopt -s extglob
$ 4.2.20 16 515---> ls ?a
NetworkSystemAdministration.pdf
accident
$ 4.2.20 17 516---> ls !a
ls apropos "device driver"
ls: cannot access apropos: No such file or directory
ls: cannot access device driver: No such file or directory
$ 4.2.20 18 517---> shopt -u extglob
$ 4.2.20 19 518---> ls !a
ls apropos "device driver"
ls: cannot access apropos: No such file or directory
ls: cannot access device driver: No such file or directory
$ 4.2.20 20 519--->
 ! is a history expansion character in GNU bash

shopt . file expansion . shell option failglob

commandline session

$ 4.2.20 29 495---> shellp *tcl
:*tcl:
$ 4.2.20 30 496---> shopt -s failglob
$ 4.2.20 31 497---> shellp *tcl
bash: no match: *tcl
$ 4.2.20 32 498---> shopt -u failglob
$ 4.2.20 33 499---> shellp *tcl
:*tcl:
$ 4.2.20 34 500---> shellp *t
:aio.out:
:a.out:
:backsubmit.txt:
:dpkg--list.output.txt:
:icon-tut:
:incomplete-resume.txt:
:ls.txt:
:movie-current:
:music.web.txt:
:output.bubble-sort:
:pagination.code.txt:
:random.a1.txt:
:random.a.modify.txt:
:random.a.txt:
:random.bin.txt:
:result:
:resume.txt:
:rt:
:sent:
:setup.a.txt:
:stdout:
:test:
:tiles.txt:
:true.false.command.txt:
:url?sa=t:
:wget:
$ 4.2.20 35 501--->

shopt . six shell options . nullglob

commandline session

$ 4.2.20 8 463---> shellp *hacker
:*hacker:
$ 4.2.20 9 464---> shopt -s nullglob
$ 4.2.20 10 4100---> shellp *hacker
::
$ 4.2.20 11 466---> shellp *t
:aio.out:
:a.out:
:backsubmit.txt:
:dpkg--list.output.txt:
:icon-tut:
:incomplete-resume.txt:
:ls.txt:
:movie-current:
:music.web.txt:
:output.bubble-sort:
:pagination.code.txt:
:random.a1.txt:
:random.a.modify.txt:
:random.a.txt:
:random.bin.txt:
:result:
:resume.txt:
:rt:
:sent:
:setup.a.txt:
:stdout:
:test:
:tiles.txt:
:true.false.command.txt:
:url?sa=t:
:wget:
$ 4.2.20 12 467--->

function implementation for bash shell

commandline session

$ 4.2.20 44 301---> cat .bashrc
#export PS1="[ 33[0;31m] $ V # ! "
export PS1="$ V # !---> "

shellp()
{
pre=: post=:
printf "$pr%s$pon" "$@"
}

$ 4.2.20 45 302---> shellp hacker cracker maker
hacker
cracker
maker
$ 4.2.20 46 303--->

$ 4.2.20 2 457---> cat .bashrc
#export PS1="[ 33[0;31m] $ V # ! "
export PS1="$ V # !---> "

shellp()
{
pre=: post=:
printf "$pre%s$postn" "$@"
}

$ 4.2.20 3 458---> shellp hacker cracker maker
hacker
cracker
maker
$ 4.2.20 4 459---> source .bashrc
$ 4.2.20 5 460---> shellp hacker cracker maker
:hacker:
:cracker:
:maker:
$ 4.2.20 6 461--->