I have a comma seperated delimited file with 10 columns. I need to convert it into TAB seperated delimited file.
how to use OFS to get the same output. I have tried by googling, but it is not working. The reason is, if in future, the column will be added in source file, i have to change my script. Using OFS, i do not need to change it.
Hi,
I have these out put field seperator changed to "|" in my awk command, but it didn't give me the result.
Can someone help me find out why?
=======================================
/bin/awk 'BEGIN { OFS="|" } { print $0 }' list.tmp.$$ > listtmp.$$
=======================================... (1 Reply)
OFS is inbuild command in awk.
I have a file file.txt
abc : def : ghi
jkl : mno: pqr
stu : vwx :yzz
code i used:
awk -F ":" 'BEGIN {OFS="|"} {print $1,$2}' file.txt
output:
abc def
jkl mno
stu vwx
but as i have used OFS="|" and i am expecting output as:
abc | def
jkl... (4 Replies)
Hi,
I am trying to parse regular XML file where I have to reduce number of decimal points in some xml elements. I am using following AWK command to achive that :
#!/bin/ksh
EDITCMD='BEGIN { FS = ""; OFS=FS }
{
if ( $3 ~ "*\\.*" && length(substr($3,1+index($3,"."))) == 15 ) {... (4 Replies)
I have a file that looks like this:
Infile.seq
I want to output the DNA sequence and add the filename as the identifier. The output file should look like this:
I am using the following code but I do not understand why the sequence is not in the output:
awk 'BEGIN { RS =... (11 Replies)
Hi Im trying to tidy up the output of a who command when it writes to a log, everything I've tried doesnt seem to work though, any help would be massively appreciated. Im using the awk command to set the OFS as tab.
#!/bin/bash
who >> /export/home/tjmoore/logusers
awk -F 'BEGIN... (3 Replies)
Hi, Could anyone tell me what Im doing wrong here any help will be much appreciated
#!/bin/bash
ls -ltr /export/home/tjmoore > /export/home/tjmoore/log100
awk -F " " /export/home/tjmoore/log100 'BEGIN {OFS="\t";} {print $1,$2,$3,$4,$5,
$6,$7,$8,$9;}' > /export/home/tjmoore/log1001
I... (9 Replies)
Hello,
I have an issue with adding commas as delimiters in this scenario:
cat xtr3.rpl|head -5|awk 'BEGIN {OFS=","} {print $1,$2,$3,$4}'
Produces this output:
00530083,0000000471,000000000000.00,000000000000.00
00530085,0000000471,000000000000.00,000000000000.00... (10 Replies)
file:
sasa|asasa|asasa|asas
erer|Erer|rere|ererer
Output needed :
sasa:asasa:asasa:asas
erer:Erer:rere:ererer
Im getting output, when i use the $1,$2.
awk -F'|' 'BEGIN{OFS=":";} {print $1,$2; }' file
Output :
sasa:asasa
erer:Erer
But when i need the whole column, i... (5 Replies)
Hi ,
I am having a problem with my awk oneliner , which for some reason leaves the first two records
Input File
$ cat file1
A1:B1:C1:NoLimit
M1:M2:M3:Limit
A2:B2:C2,C3,C4,C5
A3:B3:C3,C4,C5,C6,C7Desired output
A1,B1,C1,NoLimit
M1,M2,M3,Limit
A2,B2,C2
,,,C3
,,,C4
,,,C5
A3,B3,C3... (5 Replies)
STAG-FLATTEN(1p) User Contributed Perl Documentation STAG-FLATTEN(1p)NAME
stag-flatten - turns stag data into a flat table
SYNOPSIS
stag-flatten -c name -c person/name dept MyFile.xml
DESCRIPTION
reads in a file in a stag format, and 'flattens' it to a tab-delimited table format. given this data:
(company
(dept
(name "special-operations")
(person
(name "james-bond"))
(person
(name "fred"))))
the above command will return a two column table
special-operations james-bond
special-operations fred
If there are multiple values for the columns within the node, then the cartesian product will be calculated
USAGE
stag-flatten [-p PARSER] [-c COLS] [-c COLS] NODE <file>
ARGUMENTS
-p|parser FORMAT
FORMAT is one of xml, sxpr or itext
xml assumed as default
-c|column COL1,COL2,COL3,..
the name of the columns/elements to write out
this can be specified either with multiple -c arguments, or with a comma-seperated (no spaces) list of column (terminal node) names
after a single -c
-n|nest
if set, then the output will be a compress repeating values into the same row; each cell in the table will be enclosed by {}, and will
contain a comma-delimited set of values
SEE ALSO
Data::Stag
perl v5.10.0 2008-12-23 STAG-FLATTEN(1p)