Working with Tab-Delimited files
I have a tab-Delimited file:
Eg: 'test' file contains: a<tab>b<tab>c<tab>.... Based on certain condition, I wanna increase the number of lines of this file.How do I do that Eg: If some value in the database is 1 then one line in 'test' file is fine.. If some value in the database is 2 then 2 lines in the 'test' file is required with the second line not matching the first line(this is req since i wanna perform a replace command later(Eg: replace 'a' with '1') Eg: 'test' file will then contain: a<tab>b<tab>c<tab>.... d<tab>e<tab>f<tab>.... i need to simulate this using a shell scripts..kindly help me.. |
Accessing a DB from shell is a bit fiddly, but when you've done that you can just append a line to the file each time eg
line=a<tab>b<tab>c echo $line >>filename |
Thanks for ur reply Chrish, however the result i got was this:
<Empty line> a<space>b<space>c.. Now im not sure if that space qualifies for a <tab>..do we have to convert it using tr or sumtng..lemme know.. |
Try:
Code:
echo -e "a\tb\tc" >> file be translated to the proper ASCII char. See man echo for details. Check out also: Code:
man ascii |
Thanks timmeke..worked fine..But another question..
Suppose there is req ie: a<Tab>b<Tab>c<Tab>d<space>e<Tab> Then how do we go ahead with this...for tab we use \t..is there anytng for space??? i check man echo didnt find anytng :( Kindly lemme know |
\s is space, but doesn't seem to work with "echo". However, you can just type spaces too. Just don't forget the double (or single) quotes.
Example: Code:
echo -e "a\tb\tc\td e\tf" |
All times are GMT -5. The time now is 07:33 AM. |