I need to append the data in to a file by using tab delimiter. eg: echo "Data1" >> filename.txt echo "\t" >> filename.txt (its not working) echo "Data2" >> filename.txt.
Different shells and different versions of echo work slightly differently, but a literal tab character should always work. At the prompt, you might need to type <ctrl-v> <tab> to get a literal tab.
Note that echo will add a newline (in some versions you can suppress that with the -n option, or with an escape code \c) so it might be better to simply put everything on one line.
Or you could pick a unique punctuation character and change it to tab with tr -- again, different shells and different versions of tr might work slightly differently, but this works for me:
(010 is the octal ASCII code for the tab character. Maybe your tr doesn't understand octal. Maybe your tr does understand '\t' instead. Experiment, and Google.)
Last edited by era; 07-30-2008 at 07:58 AM..
Reason: Note about echo -n
But as noted earlier, there are dialects of echo and not all of them work like that. printf is at least somewhat more portable. Or to paraphrase the immortal words of the creator of Perl (Larry Wall: "It is easier to write a portable shell than to write a portable shell script"), use a portable language instead. (Hint: Perl.)
My file has data that looks like below:
more data.txt
I wish to display each string seperated by a delimiter :
Expected output:
I tried the below but I m not getting every split string on a new line.
#!/bin/bash
for i in `sed 's/:/\\n/g' data.txt`;
do
echo -n... (2 Replies)
Dear All,
I would like to find an automatic way to add a given code which belong to a class at the end of the column , for example this is my input file:
0610009O20Rik
V$VMYB_01 310 (+) 1 0.971 v-Myb
V$EVI1_04 782 (-) 0.763 0.834 Evi-1
V$ELK1_02 1966 (-) 1 0.984 Elk-1... (4 Replies)
Hi,
I have two files like:
file1
chr1 40
chr1 50
chr2 10
chr2 60
file2
chr1 30
chr1 50
chr2 15
chr2 20
and want to get the difference of column 2 when column 1 is the same in both files. (4 Replies)
I have a file having the following entries:
test1 test2 test3
11 22 33
22 44 66
99 99 44
---
I want to add a column so that the above file becomes:
test1 test2 test3 notest
11 22 33 *
22 44 66 *
99 99 44 *
---
Thanks (6 Replies)
I have the following script working fine, and need to generate a file delimiter (with tab or special character) for Excel data import. The script will run every hour in crontab to append the new rows to the delimiter, so that I can collect the data for i.e. a week, which will give me a lot of... (0 Replies)
Hello,
Is there a direct command to check if the delimiter in your file is a tab or a space? And how can they be converted from one to another.
Thanks,
G (4 Replies)
hi every one
plz help me
i want to search for a line contains tabspace
This is a line The should be changed
see the above line is seperated with tab space i want to replace that tab space in to # as
This is a line#The should be changed
i have tried with... (4 Replies)
I have a 30 column tab delimited record file. I need to extract the first 10column. The following command to cut was not working
cut -f 1-10 -d "\t" filename.
Could any one keep on this .
Thanks in Advance (4 Replies)
HI
can any one tell me how to replace a delimiter : with another delimiter '\001' it is a non printable octal character.
thanks in adv
spandu (4 Replies)