Stripping out tabs in file before redirecting to command.
Good morning All,
Real simple question, but for some reason I cannot figure it out. I have 2 files <file1> <file2> that I need to compare and then send to a command. However, the file contains tabs that I must strip out prior to sending to the command. This is what I got so far: Code:
lpr < diff file1 file2 Basically I need to now what the argument is that I place next to the '<' to strip out the tabs. I look forward to your response. s |
use sed
Quote:
|
oneindelijk said,
Quote:
I am aware of sed and all of its abilities, removing the tabs or comparing files or redirecting the output to lpr individually is not the problem. I am looking for an elegant method of doing this in one line. |
maybe multitail is what you're looking for ?
I'm not sure it's capable of comparing though |
So is it just a case of putting it all together?
Code:
lpr < diff <(sed 's/\t//g' file1) <(sed 's/\t//g' file2) |
grail said,
Quote:
Code:
lpr <<- diff file1 file2 I appreciate all of your help. Thank you. s |
I am curious how the '-' strips out tabs? Do you have any links explaining this?
|
Here you go:
http://publib.boulder.ibm.com/infoce...put_inline.htm However, it is not a concise definition of the operator/attribute. It just tells you what <<- does. Unfortunately that does not help, but it does what it says it is supposed to. Thanks again for the help. S |
Code:
lpr <<- diff file1 file2 In any case, the link you gave also appears to describe a standard here document, as used by bash and most other shells: Code:
command <<-ENDSTRING Also, the extra "-" on the heredoc only strips any leading tabs off of the beginning of each line inside the heredoc, allowing you to indent the contents for better readability. It doesn't strip out any other tabs in the text. grail's post used bash-specific process substitution, btw, which wouldn't work in any other shell. You would have to use something like temporary files and named pipes to do it otherwise. Finally, I'd recommend tr instead of sed for removing individual characters from text. It's the most common option for such things. |
David the H said,
Quote:
As far as what you have and/or have not seen before, I am not aware of. I am learning the nuances of UNIX/Linux and love to get input from professional individuals. Brow-beating or condescending view points I have no time for. If I have misread the tone of your post please forgive my directness. I do appreciate the lesson on where I was lacking in my initial post. In the future, I will be more diligent in my verbiage. s |
But that's just it. The line you gave in post #6 simply can not work in sh, or any variation of it that I know of. And the link you gave doesn't describe the syntax you used or the actions you prescribe to it either.
Either the actual command you used is different from what you posted here, or the command isn't actually doing what you think it's doing. In other words, it's just plain wrong, and only coincidentally giving you what you want in this particular instance. The best I can guess that's happening is that the shell is erroring out on the improperly designed heredoc, ignoring it and the "diff" word, which it thinks is the delimiting string (in a script it appears to just read to the end of the file), and simply sending the raw text files straight into lpr. |
All times are GMT -5. The time now is 05:52 AM. |