Skip to main content
added 88 characters in body
Source Link
Siva
  • 9.3k
  • 9
  • 60
  • 88

Try this,

grep -r abcd | awk -F ':' '{gsub(/.*\//,"",$1) }1' | awk '!seen[$1]++'
  • gsub will remove directory structure. (/.*\//,"",$1) will remove("") all(.*) before the last match of '/' in first field($1).
  • !seen[$1]++ will uniq the filename.

Note: directory name must not have : in it.

Try this,

grep -r abcd | awk -F ':' '{gsub(/.*\//,"",$1) }1' | awk '!seen[$1]++'
  • gsub will remove directory structure.
  • !seen[$1]++ will uniq the filename.

Note: directory name must not have : in it.

Try this,

grep -r abcd | awk -F ':' '{gsub(/.*\//,"",$1) }1' | awk '!seen[$1]++'
  • gsub will remove directory structure. (/.*\//,"",$1) will remove("") all(.*) before the last match of '/' in first field($1).
  • !seen[$1]++ will uniq the filename.

Note: directory name must not have : in it.

Source Link
Siva
  • 9.3k
  • 9
  • 60
  • 88

Try this,

grep -r abcd | awk -F ':' '{gsub(/.*\//,"",$1) }1' | awk '!seen[$1]++'
  • gsub will remove directory structure.
  • !seen[$1]++ will uniq the filename.

Note: directory name must not have : in it.