B Big Dave macrumors 6502 Original poster Mar 10, 2010 #1 I need some help with syntax. I would like to do the following: grep text$imoretext where $i is a variable I can't figure out how to make this one work. Any ideas? Thanks, Dave
I need some help with syntax. I would like to do the following: grep text$imoretext where $i is a variable I can't figure out how to make this one work. Any ideas? Thanks, Dave
chown33 Moderator Staff member Mar 10, 2010 #2 Do you mean "where $i is a shell variable"? If so: Code: grep "text${i}moretext" This question has nothing to do with grep itself. It's about how to delimit shell-variable names so they don't combine with adjacent literal text. See the "Parameter Expansion" subsection of the bash man page: http://developer.apple.com/mac/library/DOCUMENTATION/Darwin/Reference/ManPages/man1/bash.1.html
Do you mean "where $i is a shell variable"? If so: Code: grep "text${i}moretext" This question has nothing to do with grep itself. It's about how to delimit shell-variable names so they don't combine with adjacent literal text. See the "Parameter Expansion" subsection of the bash man page: http://developer.apple.com/mac/library/DOCUMENTATION/Darwin/Reference/ManPages/man1/bash.1.html