Sponsored Content
Full Discussion: Want to split awk command
Top Forums Shell Programming and Scripting Want to split awk command Post 302828061 by Don Cragun on Monday 1st of July 2013 01:37:10 PM
Old 07-01-2013
I think you'll find that Yoda's suggestion add lots of additional spaces to the output at the line breaks in his code. I think the following will do what you want:
Code:
awk -F"\t" '{printf "%-1s;%-12s;%-2s;%-12s;%-12s;%-1s;%-12s;%-6s;%-12s;" \
    "%-4s;%-12s;%-20s;%-8s;%-3s;%-11s;%-6s;%-15s;%-11s;%-105s;%-70s;%-35s;" \
    "%-35s;%-35s;%-35s;%-35s;%-35s;%-90s;%-15s;%-70s;%-2s;%-10s;%-4s;%-4s;" \
    "%-35s;%-60s;%-12s;%-12s;%-35s;%-70s;\n",$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,
    $11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29,
    $30,$31,$32,$33,$34,$35,$36,$37,$38,$39}' san

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk command to split in to 2 files

Hi, I have a problem in grepping a file for 2 strings and writing them to 2 appropriate files. I need to use the awk command and read the file only once and write to the appropriate file. My file is very huge in size and it is taking a long time using cat command and grep command. Can anyone... (3 Replies)
Discussion started by: m_subra_mani
3 Replies

2. UNIX for Dummies Questions & Answers

Split a file with no pattern -- Split, Csplit, Awk

I have gone through all the threads in the forum and tested out different things. I am trying to split a 3GB file into multiple files. Some files are even larger than this. For example: split -l 3000000 filename.txt This is very slow and it splits the file with 3 million records in each... (10 Replies)
Discussion started by: madhunk
10 Replies

3. UNIX for Dummies Questions & Answers

awk split

Can anybody tell me what is wrong with this ? It does not produce anyoutput. awk 'split( "this:that", arr,":")' (2 Replies)
Discussion started by: jville
2 Replies

4. Shell Programming and Scripting

Awk command to split file name

Hi I have few files with format access.2Nov-12:15AM. These files will be generated daily . I need to write a script so that if today's date is less than 10 then it has to zip the file and rename it to acess.02Nov-12:15AM.gz .please help me in this . Also please help me in splitting the file... (10 Replies)
Discussion started by: mskalyani9
10 Replies

5. Shell Programming and Scripting

using awk in perl with split command

Hi, I have an array with following data. First field shows the owner and second is unique name. Now i have to pic the latest value with respect to the date in case of duplicate. like "def" is from two owners "rahul/vineet", now i want the latest from the two and the owner name also for all the... (9 Replies)
Discussion started by: vineet.dhingra
9 Replies

6. Shell Programming and Scripting

Split a file using awk command.

awk 'FNR == 1 { c = 1 } { print > (f c) } !FNR%n { close(f c); ++c }' n=$files_per_stream f=$input_path/filename_ $input_file $input_file with some records are splitted into files named filename_1,filename_2...etc according to $files_per_stream. Plz help me know how and if anyone has... (7 Replies)
Discussion started by: guptam
7 Replies

7. Shell Programming and Scripting

awk to split one field and print the last two fields within the split part.

Hello; I have a file consists of 4 columns separated by tab. The problem is the third fields. Some of the them are very long but can be split by the vertical bar "|". Also some of them do not contain the string "UniProt", but I could ignore it at this moment, and sort the file afterwards. Here is... (5 Replies)
Discussion started by: yifangt
5 Replies

8. Shell Programming and Scripting

awk split command to get the desired result

Dear all, I am using the awk 'split' command to get the particular value. FILE=InputFile_009_0.txt Temp=$(echo $FILE | awk '{split($FILE, a, "e_"); print a}') I would like to have the Temp take the value as : _009_0 ... (4 Replies)
Discussion started by: emily
4 Replies

9. Shell Programming and Scripting

awk split and awk calculation in the same command

I am trying to run the awk below. My question is when I split the input, then run anotherawk to perform a calculation using that splitas the input there are no issues. When I try to combine them the output is not correct, is the split not working or did I do it wrong? Thank you :). input ... (8 Replies)
Discussion started by: cmccabe
8 Replies

10. UNIX for Beginners Questions & Answers

awk command to split pipe delimited file

Hello, I need to split a pipe de-limited file based on the COLUMN 7 value . If the column value changes I need to split the file Source File Payment|ID|DATE|TIME|CONTROLNUMBER|NUMBER|NAME|INDICATOR 42156974|1137937|10/1/2018|104440|4232|2054391|CARE|1... (9 Replies)
Discussion started by: rosebud123
9 Replies
moncmd(1)							      moncmd								 moncmd(1)

NAME
moncmd - send commands to mon daemon and show the results. SYNOPSIS
moncmd [-a] [-d] [-l username] [-f file] [-s server] [-p port] [command] DESCRIPTION
moncmd sends commands to the mon server. OPTIONS
-a Authenticate with the server. -d enable debugging, which is the same as -s localhost. -f file Read and execute commands from file. -l username Supply username as the username while authenticating to the server. -s server Connect to server. -p port Use TCP port port when connecting to the server, instead of the default of 32777. MONITOR HOST
moncmd will use the host specified by the -s parameter as the server. If there is no -s parameter it will use the host specified in the MONHOST environment variable. If there is no host in either of these locations it will exit with an error. BATCH OPERATION
If no commands are supplied to moncmd on the command line, then commands will be taken from either standard input, or from the file speci- fied by the -f parameter. If standard input is connected to a TTY and the -a option is supplied, then it will prompt for a password. If the -a option is supplied without the -f option and standard input is not a TTY, then the username and password are read from standard input using the syntax "USER=username" and "PASS=password". The remaining input lines are interpreted as commands to send to the server. moncmd will not take usernames or passwords from a file, for obvious security reasons. If the username is neither supplied by the -l parameter or through standard input, it is taken from the effective user ID of the current process. COMMANDS
The following is a list of the commands that the server understands. enable | disable service group servicename Enables/disables alerts for group and servicename. All disabled states are automatically saved to the state file, which may option- ally be re-loaded upon restarting or initial startup of the server. ack group service comment Acknowledge a failure condition. This will store comment in the state of service (queryable by doing a list opstatus command), and will surppress further alerts for the service. Once the service returns to a non-failure state, then the acknowledgement is reset. version Displays the protocol version in the form of "version num" where num is the protocol version number. list aliases Lists aliases. list aliasgroups Lists alias groups. savestate Save the state of the server. Currently, the only state which is saved is the host/watches/services which are disabled. loadstate Load the state of the server. Currently, the only state which is loaded is the host/watches/services which are disabled. enable | disable host hostname Enables/disables host hostname in all groups. When the monitor is called, this hostname will not be included in the list of host- names sent to the monitor. If a group has only one hostname in it, then the enable | disable watch command should be used instead. enable | disable watch watchgroup Enables/disables an entire watch for watchgroup, as defined in the configuration file. Disabling a watch not only stops alerts from happening, but it stops the actual monitor processes from being scheduled. reset Resets the server, forcing it to re-read the configuration file, kill off currently running monitors, restart all monitoring, and reset all counters. This command is only accessible if moncmd connects from the host which is running the mon server. reset stopped Resets the server and immediately stops the scheduler. This is an atomic version of the commands reset and stop. reload auth Reloads the auth.cf file in order to incorporate any new changes. The auth table is completely re-generated; it is not merged. reset keepstate If the word "keepstate" comes after the reset command, the server will do a "loadstate" right after the reset, before the scheduler kicks back in. stop Stops the scheduler, but continues to allow client connections. start Re-starts the scheduler after it has been stopped. test monitor group servicename Triggers a test for group and service immediately by setting the service's countdown timer to zero. test (alert | upalert | startupalert) group servicename retval period Triggers a test alert, upalert, or startupalert for group and servicename. retval is the integer exit value to pass to the alert via the MON_RETVAL environment variable. You must also specify the period as it appears in the configuration file. All alerts of the given type in that period will be triggered, but the alert will not be logged. servertime Returns the current time of the server as seconds since Jan 1, 1970. list group groupname Lists the members of group groupname. list descriptions List the descriptions of each service, as defined in the configuration file. If a service description is undefined, then it is not listed. list alerthist Lists the last alarms triggered for each service of each watch group, in addition to the summary output. The number of alerts to keep in memory is bounded by the maxkeep variable, configurable on the mon command line at startup, and expandable with the set com- mand during runtime. list failurehist Lists the last failures, in addition to the summary output. This is also limited by the maxkeep variable. list opstatus Lists operational status of all services. Reports whether the last time a service group was tested resulted in success or failure. The output is: group service untested group service time timeleft succeeded group service time timeleft failed output where output is the first line of output from the monitor script which failed, time is the time that the condition was last noticed in time(2) format, and timeleft is the number of seconds left until the service is tested again. list successes Generates the same output as the list opstatus command, but only shows the services that have succeeded the last time they were tested. list failures Generates the same output as the list opstatus command, but only shows the services that have failed the last time they were tested. list disabled Lists all hosts and services which have been disabled by the disable host|service command. list pids Shows the currently active watch groups/services along with their process IDs, and it process ID of the server daemon. list watch Lists all watches and services. list state Lists the state of the scheduler. set group service variable value Sets a variable to value. Useful for temporarily changing an interval or alertevery value. Be careful, because this can just set any value in the %watch hash, and some values that are specified in the configuration file like "10m" or "35s" are converted and stored as just plain integer seconds (e.g. "alertevery"). get group service variable Displays the value of group service variable. set variable value Assigns value to the global variable variable. set opstatus group service value Sets the opstatus value for group and service. get variable Shows the value of global variable variable. term Terminates the server. This command is only accessible if moncmd connects from the host which is running the mon server. ENVIRONMENT VARIABLES
MONSERVER The hostname of the server which runs the mon process. MONPORT The port number to connect to. SEE ALSO
mon(8) BUGS
Report bugs to the email address below. AUTHOR
Jim Trocki <trockij@arctic.org> Linux $Date: 2005/04/17 07:42:27 $ moncmd(1)
All times are GMT -4. The time now is 01:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy