Search code examples
bashsedcut

Print out the string between first two “;” in Bash


I was wondering how can I get the string between the first two ";" with sed in Bash..

for example:

input:

END; startprocess -noprint; CWD: 8995; RUID: nmsadm; EUID: nmsadm;  ERRCODE: 0;

output:

startprocess -noprint

Solution

  • cut to the rescue:

    cut -d';' -f2
    

    Test

    $ cut -d';' -f2 <<< "END; startprocess -noprint; CWD: 8995; RUID: nmsadm; EUID: nmsadm;  ERRCODE: 0;"
     startprocess -noprint