Sponsored Content
Full Discussion: gawk script
Top Forums Shell Programming and Scripting gawk script Post 302200214 by zoo591 on Wednesday 28th of May 2008 07:42:23 PM
Old 05-28-2008
Nicely done. You are numero uno AWK!Smilie

Quote:
Originally Posted by awk
Code:
ls -la | awk '/^d/ && length($9) <= 8 {
          if ( $9 == "." || $9 == "..") next;
          F[++j]=$0;
          if (max1 < length($9)) max1=length($9);
          if (max2 < length($1)) max2=length($1);
          if (max3 < length($3)) max3=length($3);
          if (max4 < length($4)) max4=length($4);
          if (max5 < length($6)) max5=length($6);
          if (max6 < length($7)) max6=length($7);
          if (max7 < length($8)) max7=length($8);
}
END{ for (i=1; i<=j; i++)
   {
    split(F[i], M);
    printf "%-*s %-*s %-*s %-*s %-*s%*s %*s\n", max1, M[9], max2, M[1], max3, M[3], max4, M[4], max5, M[6],max 6, M[7],max7, M[8]
   }
}'

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to use variables and gawk in a script?

Hi, I want to define variables in a shell script and make gawk use them to make some operations Mfn = $(grep " 1 " $fitxer | gawk '{print $2}') Xfn = $(grep " 1 " $fitxer | gawk '{print $3}') Yfn = $(grep " 1 " $fitxer | gawk '{print $4}') Zfn = $(grep " 1 " $fitxer | gawk... (9 Replies)
Discussion started by: pau
9 Replies

2. UNIX for Dummies Questions & Answers

Calculating field using AWK, or GAWK script

Hello all, I'm totally new to UNIX/Linux but I'm taking a course in it at my local JC. My question: I have been tasked with writing a gawk script that will create a nicely formatted report. That part I've done ok on...however, the very last thing that must be done is a calculation of a... (4 Replies)
Discussion started by: Trellot
4 Replies

3. Shell Programming and Scripting

Issues with filtering duplicate records using gawk script

Hi All, I have huge trade file with milions of trades.I need to remove duplicate records (e.g I have following records) 30/10/2009,trdeId1,..,.. 26/10/2009.tradeId1,..,..,, 30/10/2009,tradeId2,.. In the above case i need to filter duplicate recods and I should get following output.... (2 Replies)
Discussion started by: nmumbarkar
2 Replies

4. Shell Programming and Scripting

Help with gawk script that aggregates ip address ranges

Howdy folks, perhaps someone can help me with this problem. My knowledge of awk is not the best... but I've managed to a certain degree and now I'm stuck. These are the steps and the format outputs, problem is written in red text after the STEP 2: STEP 1 Unformated text file (100+... (3 Replies)
Discussion started by: gustisok
3 Replies

5. Programming

need help with gawk script

hi i've already created this script. When I execute the script it takes the argument and compares it to the 3rd column of the script. What I was wondering if I could get some help with is. I want to add another column to the script and it will be the result of a set number for example, (2000 - 3rd... (3 Replies)
Discussion started by: gengar
3 Replies

6. Windows & DOS: Issues & Discussions

Gawk Script in Windows batch file - Help

Good morning all. I have been running into a problem running a simple gawk script that selects every third line from an input file and writes it to an output file. gawk "NR%3==0" FileIn > FileOut I am attempting to run this command from a batch file at the command line. I have several hundred... (6 Replies)
Discussion started by: 10000springs
6 Replies

7. Shell Programming and Scripting

Help with gawk array, loop in tcsh script

Hi, I'm trying to break a large csv file into smaller files and use unique values for the file names. The shell script i'm using is tcsh and i'm after a gawk one-liner to get the desired outcome. To keep things simple I have the following example with the desired output. fruitlist.csv apples... (6 Replies)
Discussion started by: theflamingmoe
6 Replies

8. Shell Programming and Scripting

gawk script to search and replace text in a flat file

Hi I am new to unix and newbie to this forum. I need help in writing a gawk script that search and replace particular text in a flat file. Input file text : ZIDE_CONTROL000 100000000003869920900000300000001ISYNC 000002225489 0000000002232122 20120321 16:40:53 ZIDE_RECORD000... (5 Replies)
Discussion started by: gkausmel
5 Replies

9. Shell Programming and Scripting

[BASH] Gawk + MYSQL script

Hello! I've got script to write. It should read databases (names, volumes) from table testdatabase and compares it to actually existing databases in /var/lib/mysql/. If there is no informations about database in table - we should see information "There is no declared informations about database... (1 Reply)
Discussion started by: Zimny
1 Replies

10. Shell Programming and Scripting

Gawk program not working in a script

I've written a very simple gawk program which runs when I execute it at the POSIX shell but the corresponding '.awk' script I wrote doesn't return any data. I'm on an HP-UX running gawk version 3.1. (w/all the defaults) (As you can probably guess I'm a newbie going through the manual and trying... (2 Replies)
Discussion started by: RUCerius
2 Replies
OCF_HEARTBEAT_IPADDR(7) 					OCF resource agents					   OCF_HEARTBEAT_IPADDR(7)

NAME
ocf_heartbeat_IPaddr2 - Manages virtual IPv4 addresses (Linux specific version) SYNOPSIS
IPaddr2 [start | stop | status | monitor | meta-data | validate-all] DESCRIPTION
This Linux-specific resource manages IP alias IP addresses. It can add an IP alias, or remove one. In addition, it can implement Cluster Alias IP functionality if invoked as a clone resource. SUPPORTED PARAMETERS
ip The IPv4 address to be configured in dotted quad notation, for example "192.168.1.1". (unique, required, string, no default) nic The base network interface on which the IP address will be brought online. .sp If left empty, the script will try and determine this from the routing table. .sp Do NOT specify an alias interface in the form eth0:1 or anything here; rather, specify the base interface only. .sp Prerequisite: .sp There must be at least one static IP address, which is not managed by the cluster, assigned to the network interface. .sp If you can not assign any static IP address on the interface, modify this kernel parameter: sysctl -w net.ipv4.conf.all.promote_secondaries=1 (or per device) .sp (optional, string, default eth0) cidr_netmask The netmask for the interface in CIDR format (e.g., 24 and not 255.255.255.0) .sp If unspecified, the script will also try to determine this from the routing table. (optional, string, no default) broadcast Broadcast address associated with the IP. If left empty, the script will determine this from the netmask. (optional, string, no default) iflabel You can specify an additional label for your IP address here. This label is appended to your interface name. If a label is specified in nic name, this parameter has no effect. (optional, string, no default) lvs_support Enable support for LVS Direct Routing configurations. In case a IP address is stopped, only move it to the loopback device to allow the local node to continue to service requests, but no longer advertise it on the network. (optional, boolean, default false) mac Set the interface MAC address explicitly. Currently only used in case of the Cluster IP Alias. Leave empty to chose automatically. .sp (optional, string, no default) clusterip_hash Specify the hashing algorithm used for the Cluster IP functionality. .sp (optional, string, default sourceip-sourceport) unique_clone_address If true, add the clone ID to the supplied value of ip to create a unique address to manage (optional, boolean, default false) arp_interval Specify the interval between unsolicited ARP packets in milliseconds. (optional, integer, default 200) arp_count Number of unsolicited ARP packets to send. (optional, integer, default 5) arp_bg Whether or not to send the arp packets in the background. (optional, string, default yes) arp_mac MAC address to send the ARP packets too. .sp You really shouldn't be touching this. .sp (optional, string, default ffffffffffff) flush_routes Flush the routing table on stop. This is for applications which use the cluster IP address and which run on the same physical host that the IP address lives on. The Linux kernel may force that application to take a shortcut to the local loopback interface, instead of the interface the address is really bound to. Under those circumstances, an application may, somewhat unexpectedly, continue to use connections for some time even after the IP address is deconfigured. Set this parameter in order to immediately disable said shortcut when the IP address goes away. (optional, boolean, default false) SUPPORTED ACTIONS
This resource agent supports the following actions (operations): start Starts the resource. Suggested minimum timeout: 20s. stop Stops the resource. Suggested minimum timeout: 20s. status Performs a status check. Suggested minimum timeout: 20s. Suggested interval: 10s. monitor Performs a detailed status check. Suggested minimum timeout: 20s. Suggested interval: 10s. meta-data Retrieves resource agent metadata (internal use only). Suggested minimum timeout: 5s. validate-all Performs a validation of the resource configuration. Suggested minimum timeout: 20s. EXAMPLE
The following is an example configuration for a IPaddr2 resource using the crm(8) shell: primitive p_IPaddr2 ocf:heartbeat:IPaddr2 params ip=string op monitor depth="0" timeout="20s" interval="10s" SEE ALSO
http://www.linux-ha.org/wiki/IPaddr2_(resource_agent) AUTHOR
Linux-HA contributors (see the resource agent source for information about individual authors) resource-agents UNKNOWN 03/09/2014 OCF_HEARTBEAT_IPADDR(7)
All times are GMT -4. The time now is 01:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy