.Dd Created:2025-10-03|Updated:2025-10-21| .de ocsi \\$* , .. .de oxr .ocsi .Xr \\$* .. .de oit .It \\$* .. .de obdi .Bl -dash -compact .oit \\$* .. .de obdl .Bd -literal -compact \\$* .. .de onote .Bl -hang -compact .oit \\$* .El .. .de ocomm .Bl -diag -compact .oit \\$* .El .. .de opsy .Pp .Sy - \\$* .. .de obc .Bl -column \\$* .. .de obc2 .obc opt desc .. .de obc3 .obc option arguments description .. .Dt TEXT_MANIPULATION oh .Nm text manipulation .Nd tools .Tg index .Bl -column -offset indent ".Sy Xr roff_supported oh " ".Sy roff_supported (oh) " .It Li Xr sed oh Ta : text stream editor, commonly used for substitution. .It Li Xr cut oh Ta : split string. .It Li Xr tr oh Ta : translate characters. .It Li Xr paste oh Ta : join files/lines. .El .Sh SED .obc2 .It replace old with new Ta : Li s/old/new/ .It replace all occurrences Ta : Li s/old/new/g .It replace the second occurrence Ta : Li s/l/p/2 .El .Ss Examples .obdl $ echo \&"hello\&" | sed \&"s/l/p/\&" heplo $ echo "hello" | sed "s/l/p/g" heppo $ echo "hello" | sed "s/l/p/2" helpo .Ed .Sh CUT .Bl -column ".Sy - -opt " .It -d Ta | delimeter .It -c Ta | split by character count .It -d Ta | split by character (specify delimeter) .It -f Ta | specify field count. Use n,-n,n- .D1 -f 2, gets 2nd field; -f -2, gets up to the 2nd field; -f 2-, gets from the 2nd field to the end .El .Bd -literal -compact $ echo "a b c" | cut -d " " -f 2 b $ echo "a b c" | cut -d " " -f 2- b c $ echo hello | cut -c 2 e .Ed .Sh TR .Bd -literal -compact $ echo "hello" | tr "l" "m" hemmo .Ed .Ss control chacters .obdl echo \&"hello\&" | tr 'e' '\en' h llo .Ed .Ss .obdl echo 'hello' | tr 'l' '\et' he o .Ed .Ss character range .obdl echo 'hello' | tr 'h-l' 'a-d' aeddo .Ed .Ss Character classes .obdl echo '1.hello\en2.goodbye' | tr '[:digit:]' 'a-c' b.hello c.goodbye .Ed .Sh PASTE Requires a file OpenBSD, cat be a pipe redirection on Slackware. .Ss OpenBSD .Bd -literal -compact $ cat test.log 1 2 3 $ paste -s -d "+" test.log 1+2+3 .Ed .obdl cat test.log | paste -s -d "+" 1+2+3 .Ed .Sh TODO .obdi review and improve if needed. .El .Sh SEE ALSO .oxr openbsd oh .Xr slackware oh .Sh AUTHORS .An -nosplit .Xr ohazot oh | .Xr about oh | .Lk https://ohazot.com ohazot.com .Aq Mt admin@ohazot.com