sed

Print section of a string
Extract “2.3” from “hadoop-client - 2.3.2.0-2950”

echo "hadoop-client - 2.3.2.0-2950" | sed 's/hadoop-client - \([0-9]\.[0-9]\).*/\1/'

Extract only the IP from a string.
To do this there must be a start and end character.
For example “node1 =192.168.1.50:5443 hostname” will have a start character of “=” and end is “:”.

sed 's/.*\/\(.*\):.*/\1/'
  • linux/sed.txt
  • Last modified: 2019/01/30 14:35
  • by preb