Reputation: 2553
I have
grep 5980 list.txt > temp; awk '{ print $4}' temp
but instead of just printing the results I would like to set it to an environment variable.
I'm kind of new to bash and awk so an explanation would also be much appreciated.
Upvotes: 3
Views: 3154
Reputation: 67301
If you dont need to save the output in temp,you can use the below command:
export variable=$(awk '/5980/{print $4}' list.txt)
Upvotes: 3
Reputation: 7107
export variable=$(grep 5980 list.txt > temp; awk '{ print $4}' temp)
Upvotes: 4