Sample Header Ad - 728x90

Extract parts of a string using head and tail only

0 votes
2 answers
710 views
Hello I would like to know if there is a way where I can only use head, tail, and pipes (and redirection eventually) to extract and output the start, middle characters, and end of a string Example: Given this string: SHOWpijfirefjTHISezpijSTRING, the command should output 'SHOWTHISSTRING' I tried something like (head -c 4 mdp > /dev/tty) | (tail -c +13 mdp | head -c 4 > /dev/tty) | (tail -c 6 mdp > /dev/tty) 2>&1 but it doesn't always return the same result and can give out of order results
Asked by naynay (17 rep)
Oct 22, 2023, 09:11 PM
Last activity: Oct 23, 2023, 09:49 AM