0

I compare 2 files using Cygwin (MobaXterm) diff. Output files have -- a and ++ b lines at the first line. I want to delete only these lines. How could I do it? Here's my script:

#! /bin/bash

sort -bf $1 | uniq > a
sort -bf $2 | uniq > b
/drives/c/Software/MobaXterm_Portable_v22.0/slash/bin/diff -iw a b > c
rm a b
grep ^'+' c | awk '{sub("+","");{print}}' | sed -e 's/^[[:space:]]*//' > $1_only.txt
grep ^'-' c | awk '{sub("-","");{print}}' | sed -e 's/^[[:space:]]*//' > $2_only.txt
rm c

-- Here's the output from one file:

++ b
2
4
6

Here's the output from another file:

-- a
3
5

Thanks

3
  • You missing a perl in the pipe chain...
    – gapsf
    Commented Oct 15, 2022 at 13:48
  • 1
    Add to the chain another command to remove the first line - see this post.
    – harrymc
    Commented Oct 15, 2022 at 15:54
  • All set. Adding sed command to delete the first line solved my issue. Thank you.
    – susik
    Commented Oct 15, 2022 at 23:41

0

You must log in to answer this question.

Browse other questions tagged .