Skip to content

Instantly share code, notes, and snippets.

@Remiii
Last active December 16, 2015 15:49
Show Gist options
  • Save Remiii/5458263 to your computer and use it in GitHub Desktop.
Save Remiii/5458263 to your computer and use it in GitHub Desktop.
Get line number when number of occurrences of a specific pattern in a line is different from a given argument. Usefull for test the number of columns in a CSV file.

Get line number when number of occurrences of a specific pattern in a line is different from a given argument. Usefull for test the number of columns in a CSV file.

  • myFile => file
  • myPatern => specific pattern
  • myNumberOfOccurrences => number of occurrences in a line
cat ./myFile | awk '{ split($0,a,"myPatern"); print NR " - " length(a) -1 }' | grep -v myNumberOfOccurrces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment