Main Menu

Search

Monday, August 12, 2024

LINUX: Command To Print All Characters In Lines After "/" BackSlash (Grep)

Below is the grep command to use.

grep -o '/[^/]*$' <filename> | cut -c2-

For e.g. if contents of file is as follows:

/registry/pods/kube-system/kube-flannel-ds-abcde
/registry/pods/kube-system/kube-flannel-ds-xyzab

Above command will print below

kube-flannel-ds-abcde
kube-flannel-ds-xyzab

No comments:

Post a Comment