Search code examples
bashterminalgrepcut

Cut all till the end


I have an out put in the below pattern

["snaptuda-shv-22-lla1.example.com","snaptuza-shv-22-lla1.example.com","snaptuservice-proxy-shv-22-lla1.example.com"]

I used below command to strip the domains within the double quotes

cut -d"\"" -f2 file.txt

I got only the first domain , which was

snaptuda-shv-22-lla1.example.com

What I need is all domains till the end of the file , how can I achieve this ?


Solution

  • You input is json. For parsing json there is jq:

    jq -r '.[]' filename
    

    Or if the input comes from stdout, like this:

    echo '["snaptuda-shv-22-lla1.example.com",...]' | jq -r '.[]'
    snaptuda-shv-22-lla1.example.com
    snaptuza-shv-22-lla1.example.com
    snaptuservice-proxy-shv-22-lla1.example.com