Sponsored Content
Full Discussion: AWK command
Top Forums Shell Programming and Scripting AWK command Post 302252724 by zaxxon on Thursday 30th of October 2008 07:39:26 AM
Old 10-30-2008
Code:
root@isau02:/data/tmp/testfeld> cat infile
# /dev/rdisk/dsk1c:
type: SCSI
disk: BD018635C4
label:
flags: dynamic_geometry
bytes/sector: 512
sectors/track: 254
tracks/cylinder: 20
sectors/cylinder: 5080
cylinders: 7001
sectors/unit: 35565080
rpm: 10025
interleave: 1
trackskew: 84
cylinderskew: 74
headswitch: 0 # milliseconds
track-to-track seek: 0 # milliseconds
drivedata: 0
8 partitions:
# size offset fstype fsize bsize cpg # ~Cyl values
a: 131072 0 unused 0 0 # 0 - 25*
b: 262144 131072 unused 0 0 # 25*- 77*
c: 35565080 0 unused 0 0 # 0 - 7000
d: 0 0 unused 0 0 # 0 - 0
e: 0 0 unused 0 0 # 0 - 0
f: 0 0 unused 0 0 # 0 - 0
g: 17585932 393216 unused 0 0 # 77*- 3539*
h: 17585932 17979148 unused 0 0 # 3539*- 7000
root@isau02:/data/tmp/testfeld> awk '/^a|^b|^g|^h/ && $4 == "unused" {sub(/:/,"",$1); print $1}' infile
a
b
g
h
root@isau02:/data/tmp/testfeld> t=`awk '/^a|^b|^g|^h/ && $4 == "unused" {sub(/:/,"",$1); print $1}' infile`
root@isau02:/data/tmp/testfeld> echo $t
a b g h

 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

assign a command line argument and a unix command to awk variables

Hi , I have a piece of code ...wherein I need to assign the following ... 1) A command line argument to a variable e.g origCount=ARGV 2) A unix command to a variable e.g result=`wc -l testFile.txt` in my awk shell script When I do this : print "origCount" origCount --> I get the... (0 Replies)
Discussion started by: sweta_doshi
0 Replies

2. Shell Programming and Scripting

awk/sed Command : Parse parameter file / send the lines to the ksh export command

Sorry for the duplicate thread this one is similar to the one in https://www.unix.com/shell-programming-scripting/88132-awk-sed-script-read-values-parameter-files.html#post302255121 Since there were no responses on the parent thread since it got resolved partially i thought to open the new... (4 Replies)
Discussion started by: rajan_san
4 Replies

3. UNIX for Dummies Questions & Answers

Basic awk question...getting awk to act on $1 of the command itself

I have a script problem that I am not able to solve due my very limited understanding of unix/awk. This is the contents of test.sh awk '{print $1}' From the prompt if I enter: ./test.sh Hello World I would expect to see "Hello" but all I get is a blank line. Only then if I enter "Hello... (2 Replies)
Discussion started by: JasonHamm
2 Replies

4. Shell Programming and Scripting

awk command for simple join command but based on 2 columns

input1 a_a a/a 10 100 a1 a_a 20 200 b1 b_b 30 300 input2 a_a a/a xxx yyy a1 a1 lll ppp b1 b_b kkk ooo output a_a a/a 10 100 xxx yyy (2 Replies)
Discussion started by: ruby_sgp
2 Replies

5. Shell Programming and Scripting

awk command in script gives error while same awk command at prompt runs fine: Why?

Hello all, Here is what my bash script does: sums number columns, saves the tot in new column, outputs if tot >= threshold val: > cat getnon0file.sh #!/bin/bash this="getnon0file.sh" USAGE=$this" InFile="xyz.38" Min="0.05" # awk '{sum=0; for(n=2; n<=NF; n++){sum+=$n};... (4 Replies)
Discussion started by: catalys
4 Replies

6. Shell Programming and Scripting

awk command to compare a file with set of files in a directory using 'awk'

Hi, I have a situation to compare one file, say file1.txt with a set of files in directory.The directory contains more than 100 files. To be more precise, the requirement is to compare the first field of file1.txt with the first field in all the files in the directory.The files in the... (10 Replies)
Discussion started by: anandek
10 Replies

7. Shell Programming and Scripting

Multiple command execution inside awk command during xml parsing

below is the output xml string from some other command and i will be parsing it using awk cat /tmp/alerts.xml <Alert id="10102" name="APP-DS-ds_ha-140018-componentFailure-S" alertDefinitionId="13982" resourceId="11427" ctime="1359453507621" fixed="false" reason="If Event/Log Level(ANY) and... (2 Replies)
Discussion started by: vivek d r
2 Replies

8. Shell Programming and Scripting

Pass awk field to a command line executed within awk

Hi, I am trying to pass awk field to a command line executed within awk (need to convert a timestamp into formatted date). All my attempts failed this far. Here's an example. It works fine with timestamp hard-codded into the command echo "1381653229 something" |awk 'BEGIN{cmd="date -d... (4 Replies)
Discussion started by: tuxer
4 Replies
devio(7)						 Miscellaneous Information Manual						  devio(7)

NAME
devio - device information interface SYNOPSIS
#include <sys/ioctl.h> #include <sys/devgetinfo.h> #include <sys/devio.h> DESCRIPTION
The devio interface obtains status, device attributes, and other information by polling the controlling device driver. There are three ioctl requests associated with this interface: DEVIOCGET, DEVGETINFO and DEVGETGEOM. The file <sys/devgetinfo.h> contains the structures and definitions needed by the DEVGETINFO ioctl request; the file <sys/devio.h> contains the structures and definitions needed by the DEVIOCGET and DEVGETGEOM ioctl requests. The DEVGETINFO and DEVIOCGET ioctl requests are used to obtain generic device information by polling the underlying device driver. DEVGET- INFO is used by disk and tape device drivers; DEVIOCGET is used by other kernel subsystems. For DEVIOCGET, the devget structure is the basic structured used by this request. The devget structure has the following definition: /* Structure for DEVIOCGET ioctl - device get status command */ struct devget { short category; /* Category */ short bus; /* Bus */ char interface[DEV_SIZE]; /* Interface (string) */ char device[DEV_SIZE]; /* Device (string) */ short adpt_num; /* Adapter number */ short nexus_num; /* Nexus or node on adapter # */ short bus_num; /* Bus number */ short ctlr_num; /* Controller number */ short rctlr_num; /* Remote controller number */ short slave_num; /* Plug or line number */ char dev_name[DEV_SIZE]; /* Device mnemonic */ short unit_num; /* Device unit number */ unsigned soft_count; /* Driver soft error count */ unsigned hard_count; /* Driver hard error count */ long stat; /* Generic status mask */ long category_stat; /* Category specific mask */ }; For DEVGETINFO, the device_info_t union is the top-level definition of the information returned to the device_info_t union is the top-level definition of the information returned to the DEVGETINFO ioctl request. It has the following definition: typedef union device_info { int version; /* version number */ v1_device_info_t v1; /* bus and device information */ uchar_t pad[1024]; /* unused */ } device_info_t; The v1_device_info_t structure contains all the information returned to the user data buffer by the DEVGETINFO ioctl command. This struc- ture is contained within the device_info_t structure so that the same interface can be used for various versions of the data structure. It has the following definition: typedef struct v1_device_info { int version; /* version number */ short category; /* device type, i.e., disk */ short bus; /* bus type */ char interface[DEV_STRING_SIZE]; /* interface type, i.e., HSC40 */ char device[DEV_STRING_SIZE]; /* device description */ char dev_name[DEV_STRING_SIZE]; /* device name */ ulong_t soft_count; /* number of soft errors */ ulong_t hard_count; /* number of hard errors */ v1_devtype_info_t devinfo; /* device-type information */ v1_bustype_info_t businfo; /* bus-type information */ uchar_t private[DEV_PRIVATE_LEN]; /* driver-specific */ } v1_device_info_t; The v1_bustype_info_t structure returns information about the bus type. It has the following definition: typedef struct v1_bustype_info { int adpt_num; /* controller chip relative to current adaptor */ int nexus_num; /* slot that the adaptor is using */ int bus_num; /* logical bus number for the adaptor */ int ctlr_num; /* system-wide instance number of the adaptor */ int rctlr_num; /* remote ID for the adaptor */ int slave_num; /* number of the device relative to the controlling hardware */ int unit_num; /* system-wide number of this device */ int pad0; /* unused */ union { v1_scsi_bus_info_t scsi; /* SCSI-specific */ uchar_t busdata[DEV_BUS_LEN]; /* bus-specific */ } bus; } v1_bustype_info_t; The v1_devtype_info_t union returns device-specific information. The contents of the v1_devtype_info_t union depends on the device type, either disk, tape, or other device type. The structure has the following definition: typedef union v1_devtype_info { v1_disk_dev_info_t disk; /* disk-specific status */ v1_tape_dev_info_t tape; /* tape-specific status */ uchar_t devdata[DEV_TYPE_LEN]; /* other device-type status */ } v1_devtype_info_t; For disk devices, the v1_devtype_info_t union contains a v1_disk_dev_info_t structure, defined as follows: typedef struct v1_disk_dev_info { ulong_t status; /* device status */ ulong_t capacity; /* number of blocks on the device */ ulong_t blocksz; /* number of bytes per block */ uchar_t class; /* disk class, such as diskette */ uchar_t part_num; /* total number of partitions */ uchar_t raid_level /* RAID level of the device */ uchar_t pad0; /* unused */ ushort_t media_changes; /* number of media changes (diskette) */ ushort_t pad1; /* unused */ union { struct { uchar_t density_code; /* SCSI density code */ uchar_t flags; /* SCSI flags */ } scsi; uchar_t archdata[DEV_ARCH_LEN]; /* architecture-specific */ } arch; } v1_disk_dev_info_t; For tape devices, the v1_devtype_info_t union contains a v1_tape_dev_info_t structure, defined as follows: typedef struct v1_tape_dev_info { uint_t media_status; /* current status of the media */ uint_t unit_status; /* current status of the unit */ long recordsz; /* record size, or 0 for variable-sized records */ long density_bpi; /* current density setting */ long density_bpi_wrt; /* density used for writes */ long position; /* number of records written since the last file mark */ long fm_cnt; /* number of file marks since the beginning of the tape */ uchar_t class; /* tape device class */ uchar_t pad[7]; /* unused */ union { struct { uint_t blocking_factor; /* blocking factor */ uchar_t valid_flags; /* valid flags */ uchar_t density_code; /* density code */ uchar_t buffered_mode; /* buffered mode */ uchar_t speed; /* tape speed */ uchar_t compression_code; /* compression code */ } scsi; uchar_t archdata[DEV_ARCH_LEN]; /* architecture-specific */ } arch; } v1_tape_dev_info_t; The DEVGETGEOM ioctl request is used to obtain disk geometry and attributes by polling the underlying device driver. The ioctl fails on other types of drivers which do not support DEVGETGEOM. The DEVGETGEOM may also fail if the device driver is unable to obtain geometry information. This could happen if the disk media is removable and there is no media loaded in the drive. The following example shows the basic structure used by this request: typedef union devgeom { struct { unsigned long dev_size; /* number of blocks in user area */ unsigned short ntracks; /* number of tracks per cylinder */ unsigned short nsectors; /* number of sectors per track */ unsigned short ncylinders; /* total number of cylinders */ unsigned long attributes; /* device attributes */ unsigned long sector_size; /* number of bytes per sector */ unsigned long min_trans; /* minimum transer size */ unsigned long max_trans; /* maximum transfer size */ unsigned long prefer_trans; /* perferred transfer size */ unsigned int headswitch; /* head switch time */ unsigned int trkseek; /* track-to-track seek time */ unsigned int acylinders; /* alternate cylinders per unit */ unsigned short rpm; /* rotational speed */ unsigned short interleave; /* hardware sector interleave */ unsigned short trackskew; /* sector 0 skew, per track */ unsigned short sparespertrack; /* spare sectors per track */ unsigned short sparespercyl; /* spare sectors per cylinder */ unsigned short cylskew; /* sector 0 skew, per cylinder */ } geom_info; unsigned char pad[108]; /* Allocate space for expansion */ } DEVGEOMST; The following is a description of the fields of the DEVGEOMST data structure. Many of the fields correspond to attributes that are often specified in the disk description file /etc/disktab . This ioctl is used by the creatediskbyname subroutine to dynamically generate disk- tab entries. dev_size This field contains the number of user accessible blocks on the disk. The corresponding disktab field is pc, which describes the size of the "c" partition. ntracks This field contains the number of tracks per cylinder and corresponds to the nt field of a disktab entry. nsectors This field contains the number of sectors per track and corresponds to the ns field of a disktab entry. ncylinders This field contains the number of cylinders on the disk and corresponds to the nc field of a disktab entry. attributes This field represents disk attributes. sector_size This field specifies the number of bytes per sector. min_trans This field specifies the minimum number of bytes that can be transferred at one time. max_trans This field specifies the maximum number of bytes that can be transferred at one time. prefer_trans This field specifies the preferred number of bytes in any single transfer. headswitch This field specifies the number of microseconds the disk takes to switch heads. trkseek This field specifies the number of microseconds the disk takes to seek from track to track. acylinders This field specifies the number of alternate cylinders that exist on the unit. rpm This field specifies the rotational speed of the disk. interleave This field specifies the hardware sector interleave. trackskew This field specifies the sector 0 skew, per track. sparespertrack This field specifies the number of spare sectors that exist on each track. sparespercyl This field specifies the number of spare sectors that exist on each cynlinder. cylskew This field specifies the sector 0 skew, per cylinder. pad This field is not used to store disk information. The pad element of the DEVGEOMST is used to provide room for future expan- sion of the information fields. RELATED INFORMATION
disktab(4) delim off devio(7)
All times are GMT -4. The time now is 09:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy