This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

echo with grep

 
rahulJ james
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have something like below, the result of the grep is assigned to abcd variable

abcd=`grep -n "^AB.*123456.*" /tmp/file | cut -d: -f1`

when I try to echo this result to a file using echo $abcd>> /tmp/abc it is not working
It works when I run from the command prompt and this gets assigned to abcd but when I try to print the value using echo $abcd i dont get any results..
 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems to work for me. What shell are you using? Bash, Bourne shell, Korn shell? Does the file /tmp/abc exist already before you run the echo command? Is NOCLOBBER set?

Can you echo anything into the file? For example: echo text >> /tmp/abc Does that work?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic