I left out some details but I basically have a bunch of *.csv's that I am trying to collect together into one file. The format of each *.csv matches what I posted earlier, where the filename is the first record and the second line is the data. Is there a good way to add a header row at the top of the output file? For some reason I don't believe my shell is working the way it is supposed to, so I am resorting to calling awk once to create the output file with the header row and then on the second call to populate it. Either way, thanks for your help!
---------- Post updated at 04:58 PM ---------- Previous update was at 04:47 PM ----------
My awk script looks like:
BEGIN{
RS="\n"
FS="*"
OFS=","
ST1="Channel Number"
ST2="Channel Label"
ST3="Time at Max"
ST4="Time History Max"
ST5="Time at Min"
ST6="Time History Min"
ST7="Frequency at Max Response"
ST8="Max Response"
}
{
if (FNR==1)
outputfile=$1
print ST1 ST2 ST3 ST4 ST5 ST6 ST7 ST8 >outputfile
if (FNR==2)
print $1 $2 $3 $4 $5 $6 $7 $8 >>outputfile
}
I thought this would work but it doesn't
You're close. You have a few problems:
First, the expressions passed to print need to be separated by a comma.
Second, you print the headerline to outputfile twice (because you're missing a { } pair around the commands you want to run when FNR is 1.
Third, you aren't closing any of the output files you're opening. With a small number of files, it won't matter since all open files will be closed when you get to the end. But if you have a large number of files, you may run out of file descriptors.
The default value for RS is a <newline>, so you don't need to set it.
I've made a couple of other slight changes and reformatted to make it easier to read, but this is VERY similar to what you did:
Im using awk and I want the output filename to contain the first field of the input file.
Ex.
1 dddd wwwww
1 eeeee wwww
1 wwww eerrrr
2 eeee eeeeee
I want the output files to be xxx1 and xxx2
Thank you (4 Replies)
Hi guys!
I'll make this short... Is there any good way to get the day number that first matches the Monday column from the cal command output with awk (or any other text manipulator commands) ?
I'm sorry if my question wasn't clear at all.
For example...
One cal output would be
$... (6 Replies)
Today I needed to take a look through a load of large backup files, so I wrote the following line to find them, order them by size, and print the file sizes in GB along with the filename. What happened was odd, the output was all as expected except for the first output line which had the filename... (4 Replies)
Using the attached file, the below awk command results in the output below:
I can not seem to produce the desired results and need some expert help. Thank you :).
awk -F'' '
{
id += $4
value += $5
occur++
}
END{
printf "%-8s%8s%8s%8s\n", "Gene", "Targets", "Average Depth", "Average... (3 Replies)
I am trying to use awk to place the contens of a filename in $1 and $2 followed by the data in the text file. Basically, put the filename within the text file. There are over 1000 files in the directory and as of now each file is saved with a unique name but it is not within the file. Thank you... (10 Replies)
Hello,
I'm using the awk command to insert empty columns on a tab delimited flatfile - which works fine -
=> But I'm not able to manage dynamicaly the filename of the awk output based on the source flatfile filename
I have 3 source flatfile:
flatfile_Jan-2016.csv
flatfile_Feb-2016.csv... (3 Replies)
In the below awk I am trying output to one file those lines that match between $2,$3,$4 of file1 and file2 with the count in (). I am also trying to output those lines that are missing between $2,$3,$4 of file1 and file2 with the count of in () each. Both input files are tab-delimited, but the... (7 Replies)
I am trying to use awk to create (in this example) 3 seperate text file from the unique id in $1 in file, if it starts with the pattern aa. The contents of each row is used to populate each text file except for $1 which is not needed. It seems I am close but not quite get there. Thank you :).
... (3 Replies)
Discussion started by: cmccabe
3 Replies
LEARN ABOUT OPENSOLARIS
auinfo
AUINFO(1) General Commands Manual AUINFO(1)NAME
auinfo - show information about a Network Audio System server
SYNOPSIS
auinfo [-audio servername]
DESCRIPTION
The auinfo program provides information describing a Network Audio System server. It lists the capabilities of the server, the devices
that are attached to it, the data formats that are accepted, and any predefined sounds that have been stored in the server.
EXAMPLE
The following example shows the output produced by auinfo when connected to an NCD MCX(tm) display station:
Audio Server: tcp/lemkemcx:8000
Version Number: 2.0
Vendor: Network Computing Devices Inc.
Vendor Release: 3000
Min Sample Rate: 1000
Max Sample Rate: 52000
Max Tracks: 32
Number of Formats: 7
Formats: ULAW8 LinearUnsigned8 LinearSigned8
LinearSigned16MSB LinearUnsigned16MSB
LinearSigned16LSB LinearUnsigned16LSB
Number of Elem Types: 11
Element Types: ImportClient ImportDevice ImportBucket Bundle
MultiplyConstant AddConstant Sum ExportClient
ExportDevice ExportBucket ExportMonitor
Number of Wave Forms: 0
Number of Actions: 2
Actions: ChangeState SendNotify
Number of Devices: 5
Device 0:
Changable: Gain LineMode
ID: 0x34
Kind: PhysicalInput
Use: Import
Format: LinearSigned16MSB
Num Tracks: 1
Access: Import List
Description: "Mono Channel Input"
Min Rate: 1000
Max Rate: 52000
Location: Left Right External
Gain Percent: 15
Line Mode: High
Device 1:
Changable: Gain
ID: 0x32
Kind: PhysicalOutput
Use: Export
Format: LinearSigned16MSB
Num Tracks: 2
Access: Export List
Description: "Stereo Channel Output"
Min Rate: 1000
Max Rate: 52000
Location: Left Right External
Gain Percent: 24
Num Children: 2
Children: 0x30 0x31
Device 2:
Changable: Gain
ID: 0x33
Kind: PhysicalOutput
Use: Export
Format: LinearSigned16MSB
Num Tracks: 1
Access: Export List
Description: "Mono Channel Output"
Min Rate: 1000
Max Rate: 52000
Location: Left Right External
Gain Percent: 24
Num Children: 2
Children: 0x30 0x31
Device 3:
Changable: Gain
ID: 0x31
Kind: PhysicalOutput
Use: Export
Format: LinearSigned16MSB
Num Tracks: 1
Access: Export List
Description: "Right Channel Output"
Min Rate: 1000
Max Rate: 52000
Location: Right External
Gain Percent: 24
Num Children: 0
Device 4:
Changable: Gain
ID: 0x30
Kind: PhysicalOutput
Use: Export
Format: LinearSigned16MSB
Num Tracks: 1
Access: Export List
Description: "Left Channel Output"
Min Rate: 1000
Max Rate: 52000
Location: Left External
Gain Percent: 24
Num Children: 0
Number of Buckets: 0
Bucket 0:
ID: 0x1400008
Kind: Bucket
Use: Import Export
Format: ULAW8
Num Tracks: 1
Access: Import Export Destroy List
Description: "Monty Python - Australian Table Wines"
Sample Rate: 8000
Num Samples: 697944
Bucket 1:
ID: 0x1400007
Kind: Bucket
Use: Import Export
Format: LinearUnsigned8
Num Tracks: 1
Access: Import Export Destroy List
Description: ""I'm sorry Dave, I can't do that" - HAL from 2001"
Sample Rate: 22255
Num Samples: 85504
Bucket 2:
ID: 0x1400006
Kind: Bucket
Use: Import Export
Format: LinearUnsigned8
Num Tracks: 1
Access: Import Export Destroy List
Description: ""He's dead, Jim" - Dr. McCoy"
Sample Rate: 11128
Num Samples: 31602
ENVIRONMENT
AUDIOSERVER
This variable specifies the default audio server to contact if -audio is not specified on the command line.
DISPLAY If AUDIOSERVER is not set, this variable is examined to find the name of the corresponding X Window System display.
SEE ALSO nas(1)COPYRIGHT
Copyright 1993, 1994 Network Computing Devices, Inc.
See nas(1) for a full statement of rights and permissions.
AUTHOR
Jim Fulton, Network Computing Devices, Inc.
1.9.3 AUINFO(1)