Guys How can I make this work
`find /xyz/abc/music/ |grep def`
I don\'t want to store the array in any temporary variable. How can w
If you just need the first element (or rather line), you can use head
:
`find /xyz/abc/music/ |grep def | head -n 1`
If you need access to arbitrary elements, you can store the array first, and then retrieve the element:
arr=(`find /xyz/abc/music/ |grep def`)
echo ${arr[n]}
but this will not put each line of grep output into a separate element of an array.
If you care for whole lines instead of words, you can use head
and tail
for this task, like so:
`find /xyz/abc/music/ |grep def | head -n line_number | tail -n 1`