Results 1 to 3 of 3
Hello Guys,
I am trying to store output of command to an array and then want to print, but it showing an error that "bad substitution". I am not getting ...
- 11-13-2011 #1Just Joined!
- Join Date
- Oct 2011
- Posts
- 17
How to store output of command to an array
Hello Guys,
I am trying to store output of command to an array and then want to print, but it showing an error that "bad substitution". I am not getting why it's happening.
Can anyone help me?
Thanking You,Code:#!/usr/bin/sh hr=0 min=0 i=1 last $1 | grep -w `date "+%b"` | grep -v '\(0[2-9]:.*\)' | grep -vw sshd | cut - c 66- | tr -d "[ ]\(\)" | grep -v '[a-z].*' | while read line do array[ $i ]="$line" i=$i+1 done #print an array for i in "${array[]}" do echo $i done
- 11-15-2011 #2
Have you tried using Bash, instead of sh?
linux user # 503963
- 11-15-2011 #3Just Joined!
- Join Date
- Oct 2011
- Posts
- 17
Thanks, problem is resolved.


Reply With Quote