awk output seperated by tab


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk output seperated by tab
# 1  
Old 02-24-2016
awk output seperated by tab

I am just trying to output the below awk separated by tabs. Thank you Smilie.


awk (added OFS as an attempt to itroduce tabs)
Code:
awk '{split($5,a,"-"); OFS='\t' print $1,$2,$3,a[1]}' file.bed > test.bed

The awk runs and produces all the data in 1 field instead of 4 fields.

current output
Code:
chr1    955543    955763   AGRN is in one field as of now

desired output
Code:
field1   field2       field3      field4
chr1    955543    955763   AGRN

# 2  
Old 02-24-2016
Code:
awk '{split($5,a,"-"); print $1,$2,$3,a[1]}' OFS='\t' file.bed > test.bed

This User Gave Thanks to vgersh99 For This Post:
# 3  
Old 02-24-2016
Thank you Smilie.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

awk printing leading tab in output

The awk below executes and produces the current output. it skips the header in row 1 and prints $4,$5,$6 and then adds the header row back. The problem is that it keeps the tailing tab and prints it in front of $1. I could add a pipe to remove the tab, but is there a better way to do it with on... (7 Replies)
Discussion started by: cmccabe
7 Replies

2. Shell Programming and Scripting

Seperated a Column from 'ESC' Character seperated file

Hi Experts I have an escape seperated fields in the unix file. And in the below format file I need to extract the first column. Please help its urgent. cat -v op.dat | head 24397028^ I want to extract the file in below format ( with only first column ) 24397028 2439707 thanks. ... (6 Replies)
Discussion started by: neha_suri06
6 Replies

3. Shell Programming and Scripting

awk to add tab to output of both conditions

In the below awk written by @RavinderSingh13 I have added a few lines and am trying to have the output be tab-delimited. The input is space-delimeted and the portion in bold seems to add a tab to the Not found but not the found. Thank you :). file1 One 1 Two 2 Three 3 file2 One 1... (2 Replies)
Discussion started by: cmccabe
2 Replies

4. Shell Programming and Scripting

awk output is space delimeted not tab delimeted

In the below awk the output is space delimited, but it should be tab delimited. Did I not add the correct -F and OFS? Thank you :). The input file are rather large so I did not include them, but they are tab-delimeted files as well. awk awk -F'\t' -v OFS='\t' 'FNR==1 { next } > ... (2 Replies)
Discussion started by: cmccabe
2 Replies

5. Shell Programming and Scripting

Convert comma seperated file to line seperated.

Hi, I have data like this. 1,2,3,4 Output required: 1 2 3 4 I am trying to use tr function but getting error. Help is appreciated. (6 Replies)
Discussion started by: pinnacle
6 Replies

6. Shell Programming and Scripting

output - tab formatted - awk

Dear All, Good Day. I would like to hear your suggestions for the following problem: I have a file with 5 columns with some numbers in 16 lines as shown below. Input file: Col 1 Col 2 Col 3 Col 4 Col 5 12 220 2 121 20 234 30 22 9... (3 Replies)
Discussion started by: Fredrick
3 Replies

7. Shell Programming and Scripting

perl help for comma seperated output

Hi, how can i make a comma seperated output summary. i attached the sample log file. I have to capture these data in the log file. Arcotid Time Stamp, Username, Success, Failure, Error Code, Error Message In the log snippet the userID can be found in- Code Arcot Native Server:... (3 Replies)
Discussion started by: namishtiwari
3 Replies

8. Shell Programming and Scripting

Removing blank lines from comma seperated and space seperated file.

Hi, I want to remove empty/blank lines from comma seperated and space seperated files Thanks all for help (11 Replies)
Discussion started by: pinnacle
11 Replies

9. UNIX for Dummies Questions & Answers

Problem with tab seperated file in UNIX

Hi All, I am facing a problem while getting the data from an Oracle table Problem: I am getting rows from an Oracle table to a tab seperated file. One of the columns in that table have value with in between spaces like AAAAA AAA It's loading fine to .tab file. But when... (2 Replies)
Discussion started by: pssandeep
2 Replies

10. Shell Programming and Scripting

Handling .CSV( Comma seperated value) in awk

Hi Guys, I am trying to reading in comma seperated values in awk. I can set the delimiter to be a comma, but the tricky part is that commas that appear within quotes are not to be considered as delimiters. Could someone please help. Regards, Laud (1 Reply)
Discussion started by: Laud12345
1 Replies
Login or Register to Ask a Question