Reputation: 1053
I tried searching for an answer but lost in questions. Basically I have a shell script as follows:
#!/bin/ksh
if [ $# -eq 1 ]; then
exit -1
fi
processInfo $1
At this point, processInfo returns a string of format: param1:param2:param3:param4:param5
I want to capture param4 into a variable.
ex:
param4= processInfo $1 | sed regex
It seems to be simple with sed and regex but I just lost track of it. Pls help
Upvotes: 2
Views: 793
Reputation: 247012
If you don't need to keep your script's positional parameters:
IFS=:
set -- $( processInfo "$1" )
param4="$4"
Upvotes: 0
Reputation: 360325
saveIFS=$IFS
IFS=:
array=($(processInfo $1))
IFS=$saveIFS
echo ${array[3]}
Upvotes: 0