bash tab hell
I'm having problems with bash and tabs.... I keep trying:
${dta#\#} ${dta%\#} on: 220.208.98.253 (Imagine 8 tabs here ) ERROR:"550 - REJECTED - Spammer" ( one \t ) #2007-07- 2 183 This is what I get: 220.208.98.253 ERROR:"550 - REJECTED - Spammer" #2007-07- 2 183 220.208.98.253 ERROR:"550 - REJECTED - Spammer" #2007-07- 2 183 It should give me ( According to the Advanced Bash Scripting Guide ) either: 220.208.98.253 ERROR:"550 - REJECTED - Spammer" or 2007-07- 2 183 Its not, and its driving me nuts!! how can I pull the end off of a string? One with tabs? TIA |
Can you explain what these are supposed to do?
Quote:
|
${dta#\#}
${string#substring}
Strips shortest match of $substring from front of $string. ${string%substring} Strips shortest match of $substring from back of $string. $dta is the string I need to parse. # is usually comments so.. \# is literal. # string from front % strip from back |
Quote:
You forgot the wildcard *: Code:
${dta#*\#} |
Thanks
That worked. :)
It wasn't in the examples, and I'm trying to learn a little more. Had to do something extra to get tabs, do I thought the tabs were interfering or something. |
You can enter literal tabs in the shell by typing [CNTRL]v-[TAB].
That will work with other characters as well, and will work in vim as well as konsole. Entering the TAB key by itself can trigger auto-completion instead. For some things like regular expressions in sed & awk or using printf, you can use \t. |
yes, remember the ${var%} type operators
accept shell type wild cards, not grep style. i.e a char is ? not a . As for which end of the string they are, I remember it like this: ${var#} a comment goes #here ${%} a percent goes here: 100% |
All times are GMT -5. The time now is 04:10 PM. |