-1

suppose in a file if I have " Route : 8888" , I want to get the string after the pattern "Route :"

I have used sed command, but it is printing 8888 but I want to store it into a variable and use for further processing

1 Answers1

0

So store sed's output in a variable:

ROUTE_VALUE=$(sed ... <file.txt)

Where '...' is your sed command.

$ cat rt.sh
ROUTE=`sed -n 's/.*Route = \(.*\),.*/\1/p' data.txt`
echo $ROUTE
$ bash rt.sh
8888
$ source rt.sh
8888
bipll
  • 11,747
  • 1
  • 18
  • 32