Sponsored Content
Top Forums Shell Programming and Scripting Print Specific lines when found specific character Post 302593192 by itkamaraj on Thursday 26th of January 2012 03:13:26 AM
Old 01-26-2012
Code:
$ nawk '/DISK/' *
$$ 1 | DISK | TR1311 | 1 |$$
$$ 1 | DISK | TR1312 | 1 |$$
$$ 1 | DISK | TR1317 | 1 |$$
$$ 1 | DISK | TR1313 | 1 |$$
$$ 1 | DISK | TR1319 | 1 |$$
$$ 1 | DISK | TR1314 | 1 |$$
$$ 1 | DISK | TR1315 | UNU|$$
$$ 1 | DISK | TR1311 | 2 |$$
$$ 1 | DISK | TR1312 | 2 |$$
$$ 1 | DISK | TR1317 | 2 |$$
$$ 1 | DISK | TR1315 | UNU|$$
$$ 1 | DISK | TR1311 | 3 |$$
$$ 1 | DISK | TR1312 | 3 |$$
$$ 1 | DISK | TR1311 | 3 |$$
$$ 1 | DISK | TR1312 | 3 |$$
$$ 1 | DISK | TR1311 | 3 |$$
$$ 1 | DISK | TR1312 | 3 |$$
$$ 1 | DISK | TR1317 | 3 |$$
$$ 1 | DISK | TR1315 | UNU|$$

---------- Post updated at 01:43 PM ---------- Previous update was at 01:42 PM ----------

Code:
$ nawk -F\| '/DISK/ && $4~/[0-9]/' *
$$ 1 | DISK | TR1311 | 1 |$$
$$ 1 | DISK | TR1312 | 1 |$$
$$ 1 | DISK | TR1317 | 1 |$$
$$ 1 | DISK | TR1313 | 1 |$$
$$ 1 | DISK | TR1319 | 1 |$$
$$ 1 | DISK | TR1314 | 1 |$$
$$ 1 | DISK | TR1311 | 2 |$$
$$ 1 | DISK | TR1312 | 2 |$$
$$ 1 | DISK | TR1317 | 2 |$$
$$ 1 | DISK | TR1311 | 3 |$$
$$ 1 | DISK | TR1312 | 3 |$$
$$ 1 | DISK | TR1311 | 3 |$$
$$ 1 | DISK | TR1312 | 3 |$$
$$ 1 | DISK | TR1311 | 3 |$$
$$ 1 | DISK | TR1312 | 3 |$$
$$ 1 | DISK | TR1317 | 3 |$$

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

print specific lines

I have a text file made of different blocks separated by blank lines. I need to print the blocks with odd indexes. How can I get it with awk? For example i need to print the first and the third block of a file like this: asgdg sadsd ssgsdgd ass uff fedd sddddso ieeduydd dddee deeo ssancnc... (4 Replies)
Discussion started by: littleboyblu
4 Replies

2. Shell Programming and Scripting

Print lines with specific character at nth position in a file

I need to print lines with character S at nth position in a file...can someone pl help me with appropriate awk command for this (2 Replies)
Discussion started by: manaswinig
2 Replies

3. Shell Programming and Scripting

Print lines with specific character at nth position in a file

I need to print lines with character S at nth position in a file...can someone pl help me with appropriate awk command for this (1 Reply)
Discussion started by: manaswinig
1 Replies

4. Shell Programming and Scripting

Using sed to replace specific character and specific position

I am trying to use sed to replace specific characters at a specific position in the file with a different value... can this be done? Example: File: A0199999123 A0199999124 A0199999125 Need to replace 99999 in positions 3-7 with 88888. Any help is appreciated. (5 Replies)
Discussion started by: programmer22
5 Replies

5. Shell Programming and Scripting

print first few lines, then apply regex on a specific column to print results.

abc.dat tty cpu tin tout us sy wt id 0 0 7 3 19 71 extended device statistics r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device 0.0 133.2 0.0 682.9 0.0 1.0 0.0 7.2 0 79 c1t0d0 0.2 180.4 0.1 5471.2 3.0 2.8 16.4 15.6 15 52 aaaaaa1-xx I want to skip first 5 line... (4 Replies)
Discussion started by: kchinnam
4 Replies

6. Shell Programming and Scripting

AWK Print Line If Specific Character Is Matched

Hello, I have a file as such: FFFFFFF6C000000 225280 225240 - - rwxs- FFFFFFFF79C00000 3240 3240 - - rwxs- FFFFFFFF7A000000 4096 4096 - - rwxs- FFFFFFFF7A400000 64 64 ... (3 Replies)
Discussion started by: PointyWombat
3 Replies

7. Shell Programming and Scripting

How to print with awk specific field different from specific character?

Hello, i need help with awk. I have this file: cat number DirB port 67 er_enc_out 0 er_bad_os 0 DirB port 71 er_enc_out 56 er_bad_os 0 DirB port 74 er_enc_out 0 er_bad_os 0 DirB port 75 ... (4 Replies)
Discussion started by: elilmal
4 Replies

8. Shell Programming and Scripting

How to print the specific lines?

I need to print specific lines 5,100,67,123 in a file. file name: today.csv (3 Replies)
Discussion started by: ramkumar15
3 Replies

9. Shell Programming and Scripting

Count specific character of a file in each line and delete this character in a specific position

I will appreciate if you help me here in this script in Solaris Enviroment. Scenario: i have 2 files : 1) /tmp/TRANSACTIONS_DAILY_20180730.txt: 201807300000000004 201807300000000005 201807300000000006 201807300000000007 201807300000000008 2)... (10 Replies)
Discussion started by: teokon90
10 Replies

10. UNIX for Beginners Questions & Answers

How to print lines from a files with specific start and end patterns and pick only the last lines?

Hi, I need to print lines which are matching with start pattern "SELECT" and END PATTERN ";" and only select the last "select" statement including the ";" . I have attached sample input file and the desired input should be as: INPUT FORMAT: SELECT ABCD, DEFGH, DFGHJ, JKLMN, AXCVB,... (5 Replies)
Discussion started by: nani2019
5 Replies
DISK(9) 						   BSD Kernel Developer's Manual						   DISK(9)

NAME
disk -- kernel disk storage API SYNOPSIS
#include <geom/geom_disk.h> struct disk * disk_alloc(void); void disk_create(struct disk *disk, int version); void disk_gone(struct disk *disk); void disk_destroy(struct disk *disk); DESCRIPTION
The disk storage API permits kernel device drivers providing access to disk-like storage devices to advertise the device to other kernel com- ponents, including GEOM(4) and devfs(5). Each disk device is described by a struct disk structure, which contains a variety of parameters for the disk device, function pointers for various methods that may be performed on the device, as well as private data storage for the device driver. In addition, some fields are reserved for use by GEOM in managing access to the device and its statistics. GEOM has the ownership of struct disk, and drivers must allocate storage for it with the disk_alloc() function, fill in the fields and call disk_create() when the device is ready to service requests. disk_gone() orphans all of the providers associated with the drive, setting an error condition of ENXIO in each one. In addition, it prevents a re-taste on last close for writing if an error condition has been set in the provider. After calling disk_destroy(), the device driver is not allowed to access the contents of struct disk anymore. The disk_create() function takes a second parameter, version, which must always be passed DISK_VERSION. If GEOM detects that the driver is compiled against an unsupported version, it will ignore the device and print a warning on the console. Descriptive Fields The following fields identify the disk device described by the structure instance, and must be filled in prior to submitting the structure to disk_create() and may not be subsequently changed: u_int d_flags Optional flags indicating to the storage framework what optional features or descriptions the storage device driver supports. Cur- rently supported flags are DISKFLAG_NEEDSGIANT (maintained by device driver), DISKFLAG_OPEN (maintained by storage framework), DISKFLAG_CANDELETE (maintained by device driver), and DISKFLAG_CANFLUSHCACHE (maintained by device driver). const char * d_name Holds the name of the storage device class, e.g., ``ahd''. This value typically uniquely identifies a particular driver device, and must not conflict with devices serviced by other device drivers. u_int d_unit Holds the instance of the storage device class, e.g., ``4''. This namespace is managed by the device driver, and assignment of unit numbers might be a property of probe order, or in some cases topology. Together, the d_name and d_unit values will uniquely identify a disk storage device. Disk Device Methods The following fields identify various disk device methods, if implemented: disk_open_t * d_open Optional: invoked when the disk device is opened. If no method is provided, open will always succeed. disk_close_t * d_close Optional: invoked when the disk device is closed. Although an error code may be returned, the call should always terminate any state setup by the corresponding open method call. disk_strategy_t * d_strategy Mandatory: invoked when a new struct bio is to be initiated on the disk device. disk_ioctl_t * d_ioctl Optional: invoked when an I/O control operation is initiated on the disk device. Please note that for security reasons these opera- tions should not be able to affect other devices than the one on which they are performed. dumper_t * d_dump Optional: if configured with dumpon(8), this function is invoked from a very restricted system state after a kernel panic to record a copy of the system RAM to the disk. Mandatory Media Properties The following fields identify the size and granularity of the disk device. These fields must stay stable from return of the drivers open method until the close method is called, but it is perfectly legal to modify them in the open method before returning. u_int d_sectorsize The sector size of the disk device in bytes. off_t d_mediasize The size of the disk device in bytes. u_int d_maxsize The maximum supported size in bytes of an I/O request. Requests larger than this size will be chopped up by GEOM. Optional Media Properties These optional fields can provide extra information about the disk device. Do not initialize these fields if the field/concept does not apply. These fields must stay stable from return of the drivers open method until the close method is called, but it is perfectly legal to modify them in the open method before returning. u_int d_fwsectors, u_int d_fwheads The number of sectors and heads advertised on the disk device by the firmware or BIOS. These values are almost universally bogus, but on some architectures necessary for the correct calculation of disk partitioning. u_int d_stripeoffset, u_int d_stripesize These two fields can be used to describe the width and location of natural performance boundaries for most disk technologies. Please see src/sys/geom/notes for details. char d_ident[DISK_IDENT_SIZE] This field can and should be used to store disk's serial number. Driver Private Data This field may be used by the device driver to store a pointer to private data to implement the disk service. void * d_drv1 Private data pointer. Typically used to store a pointer to the drivers softc structure for this disk device. SEE ALSO
GEOM(4), devfs(5) AUTHORS
This manual page was written by Robert Watson. BSD
February 18, 2004 BSD
All times are GMT -4. The time now is 06:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy