Sponsored Content
Top Forums Shell Programming and Scripting Print last occurrence if first field match Post 302145816 by Raynon on Thursday 15th of November 2007 09:30:44 AM
Old 11-15-2007
Print last occurrence if first field match

Hi All,

I have an input below. If the term in the 1st column is equal, print the last row which 1st column is equal.In the below example, it's " 0001 k= 27 " and " 0004 k= 6 " (depicted in bold). Those terms in 1st column which are not repetitive are to be printed as well. Can any body help me by using awk or perl ? Thanks


Input:

0001 k= 1
0001 k= 26
0001 k= 27
0002 k= 1
0003 k= 1
0004 k= 1
0004 k= 4
0004 k= 5
0004 k= 6

Output:

0001 k= 27
0002 k= 1
0003 k= 1
0004 k= 6
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to Match first field of two Files and print

Hi, I want to get script or command in Sun Unix which matches first fields of both the files and print the feilds of one files, example may make it more clear. InputFile1 ================== Alex,1,fgh Menthos,45454,toto Gothica,855,ee Zenie4,77,gg Salvatore,66,oo Dhin,1234,papapa... (3 Replies)
Discussion started by: indian.ace
3 Replies

2. Shell Programming and Scripting

last occurrence of a match through multiple files

Hi all, I have a lot of files with extension ".o" and I would like to extract the 10th line after (last) occurrence of a given string in each of the files. I tried: $ grep "string_to_look_for" *.o -A 10 | tail -1 but it gives the occurrence in the last file with extension .o ... (1 Reply)
Discussion started by: f_o_555
1 Replies

3. Shell Programming and Scripting

sed print from last occurrence match until the end of file

Hi, i have file f1.txt with data like: CHECK a b CHECK c d CHECK e f JOB_START .... I want to match the last occurrence of 'CHECK' until the end of the file. I can use awk: awk '/^CHECK/ { buf = "" } { buf = buf "\n" $0 } END { print buf }' f1.txt | tail +2Is there a cleaner way of... (2 Replies)
Discussion started by: ysrini
2 Replies

4. UNIX for Dummies Questions & Answers

Match pattern in a field, print pattern only instead of the entire field

Hi ! I have a tab-delimited file, file.tab: Column1 Column2 Column3 aaaaaaaaaa bbtomatoesbbbbbb cccccccccc ddddddddd eeeeappleseeeeeeeee ffffffffffffff ggggggggg hhhhhhtomatoeshhh iiiiiiiiiiiiiiii ... (18 Replies)
Discussion started by: lucasvs
18 Replies

5. UNIX for Dummies Questions & Answers

[Solved] Replace first occurrence after match

hey guys, i have been trying to work this thing out with sed with no luck :confused: i m looking for a way to replace only the first occurrence after a match for example : Cat Realized what you gotta do Dog Realized what you gotta do Sheep Realized what you gotta do Wolf Realized... (6 Replies)
Discussion started by: boaz733
6 Replies

6. Shell Programming and Scripting

Egrep - Only Match First Occurrence

echo 'String#1 and String#2' | egrep -o -m 1 'String#.{1}' String#1 String#2 I'm trying to just match the first occurrence of 'String#' + 1 character. I thought the "-m 1" switch would do that for me. Instead I get both occurrences. Can somebody provide some insight? Thanks! (5 Replies)
Discussion started by: sudo
5 Replies

7. Shell Programming and Scripting

Match columns and print specific field

Hello, I have data in following format. ... (6 Replies)
Discussion started by: Pushpraj
6 Replies

8. Shell Programming and Scripting

Command/script to match a field and print the next field of each line in a file.

Hello, I have a text file in the below format: Source Destination State Lag Status CQA02W2K12pl:D:\CAQA ... (10 Replies)
Discussion started by: pocodot
10 Replies

9. Shell Programming and Scripting

sed print from last occurrence match until the end of last occurrence match

Hi, i have file file.txt with data like: START 03:11:30 a 03:11:40 b END START 03:13:30 eee 03:13:35 fff END jjjjjjjjjjjjjjjjjjjjj START 03:14:30 eee 03:15:30 fff END ggggggggggg iiiiiiiiiiiiiiiiiiiiiiiii I want the below output START (13 Replies)
Discussion started by: Jyotshna
13 Replies

10. Shell Programming and Scripting

awk to print text in field if match and range is met

In the awk below I am trying to match the value in $4 of file1 with the split value from $4 in file2. I store the value of $4 in file1 in A and the split value (using the _ for the split) in array. I then strore the value in $2 as min, the value in $3 as max, and the value in $1 as chr. If A is... (6 Replies)
Discussion started by: cmccabe
6 Replies
EFIBOOTMGR(8)															     EFIBOOTMGR(8)

NAME
efibootmgr - manipulate the EFI Boot Manager SYNOPSIS
efibootmgr [ -a ] [ -A ] [ -b XXXX ] [ -B XXXX ] [ -c ] [ -d DISK ] [ -e 1|3|-1 ] [ -E NUM ] [ -g ] [ -H XXXX ] [ -i NAME ] [ -l NAME ] [ -L LABEL ] [ -n XXXX ] [ -N ] [ -o XXXX,YYYY,ZZZZ ... ] [ -O ] [ -p PART ] [ -q ] [ -t seconds ] [ -T ] [ -u ] [ -U XXXX ] [ -v ] [ -V ] [ -w ] [ -@ file ] DESCRIPTION
efibootmgr is a userspace application used to modify the Intel Extensible Firmware Interface (EFI) Boot Manager. This application can cre- ate and destroy boot entries, change the boot order, change the next running boot option, and more. Details on the EFI Boot Manager are available from the EFI Specification, v1.02 or later, available from: <URL:http://developer.intel.com> Note: efibootmgr requires that the kernel support access to EFI non-volatile variables (through /proc/efi/vars on 2.4 kernels, /sys/firmware/efi/vars on 2.6 kernels). modprobe efivars should do the trick. OPTIONS
The following is a list of options accepted by efibootmgr: -a | --active Sets bootnum active -A | --inactive Sets bootnum inactive -b | --bootnum XXXX Modify BootXXXX (hex) -B | --delete-bootnum Delete bootnum (hex) -c | --create Create new variable bootnum and add to bootorder -d | --disk DISK The disk containing the loader (defaults to /dev/sda) -e | --edd 1|3|-1 Force EDD 1.0 or 3.0 creation variables, or guess. -E | --device NUM EDD 1.0 device number (defaults to 0x80) -g | --gpt Force disk with invalid PMBR to be treated as GPT -H | --acpi_hid XXXX set the ACPI HID (used with -i) -i | --iface NAME create a netboot entry for the named interface -l | --loader NAME Specify a loader (defaults to \elilo.efi) -L | --label LABEL Boot manager display label (defaults to "Linux") -n | --bootnext XXXX Set BootNext to XXXX (hex) -N | --delete-bootnext Delete BootNext -o | --bootorder XXXX,YYYY,ZZZZ Explicitly set BootOrder (hex) -O | --delete-bootorder Delete BootOrder -p | --part PART Partition number containing the bootloader (defaults to 1) -q | --quiet Quiet mode - supresses output. --test filename Don't write to NVRAM, write to filename. -t | --timeout seconds Boot Manager timeout, in seconds. -T | --delete-timeout Delete Timeout variable. -u | --unicode | --UCS-2 pass extra command line arguments as UCS-2 (default is ASCII) -U | --acpi_uid XXXX set the ACPI UID (used with -i) -v | --verbose Verbose mode - prints additional information -V | --version Just print version string and exit. -w | --write-signature write unique signature to the MBR if needed -@ | --append-binary-args append extra variable args from file (use - to read from stdin). Data in file is appended as command line arguments to the boot loader command, with no modification to the data, so you can pass any binary or text data necessary. EXAMPLES
1. DISPLAYING THE CURRENT SETTINGS (MUST BE ROOT). [root@localhost ~]# efibootmgr BootCurrent: 0004 BootNext: 0003 BootOrder: 0004,0000,0001,0002,0003 Timeout: 30 seconds Boot0000* Diskette Drive(device:0) Boot0001* CD-ROM Drive(device:FF) Boot0002* Hard Drive(Device:80)/HD(Part1,Sig00112233) Boot0003* PXE Boot: MAC(00D0B7C15D91) Boot0004* Linux This shows: o BootCurrent - the boot entry used to start the currently running system o BootOrder - the boot order as would appear in the boot manager. The boot manager tries to boot the first active entry in this list. If unsuccessful, it tries the next entry, and so on. o BootNext - the boot entry which is scheduled to be run on next boot. This supercedes BootOrder for one boot only, and is deleted by the boot manager after first use. This allows you to change the next boot behavior without changing BootOrder. o Timeout - the time in seconds between when the boot manager appears on the screen until when it automatically chooses the startup value from BootNext or BootOrder. o Five boot entries (0000 - 0004), along with the active/inactive flag (* means active) and the name displayed on the screen. 2. CREATING A NEW BOOT OPTION An OS installer would call efibootmgr -c. This assumes that /boot/efi is your EFI System Partition, and is mounted at /dev/sda1. This creates a new boot option, called "Linux", and puts it at the top of the boot order list. Options may be passed to modify the default behavior. The default OS Loader is elilo.efi. 3. CHANGING THE BOOT ORDER Assuming the configuration in Example #1, efibootmgr -o 3,4 could be called to specify PXE boot first, then Linux boot. 4. CHANGING THE BOOT ORDER FOR THE NEXT BOOT ONLY Assuming the configuration in Example #1, efibootmgr -n 4 could be called to specify that the Linux entry be taken on next boot. 5. DELETING A BOOT OPTION Assuming the configuration in Example #1, efibootmgr -b 4 -B could be called to delete entry 4 and remove it from the BootOrder. 6. CREATING NETWORK BOOT ENTRIES A system administrator wants to create a boot option to network boot (PXE). Unfortunately, this requires knowing a little more information about your system than can be easily found by efibootmgr, so you've got to pass additional information - the ACPI HID and UID values. These can generally be found by using the EFI Boot Manager (in the EFI environment) to create a network boot entry, then using efibootmgr to print it verbosely. Here's one example: Boot003* Acpi(PNP0A03,0)/PCI(5|0)/Mac(00D0B7F9F510) ACPI(a0341d0,0)PCI(0,5)MAC(00d0b7f9f510,0) In this case, the ACPI HID is "0A0341d0" and the UID is "0". For the zx2000 gigE, the HID is "222F" and the UID is "500". For the rx2000 gigE, the HID is "0002" and the UID is "100". You create the boot entry with: efibootmgr -c -i eth0 -H 222F -U 500 -L netboot BUGS
Please direct any bugs, features, patches, etc. to Matt Domsch <Matt_Domsch@dell.com>. AUTHOR
This man page was generated by dann frazier <dannf@debian.org> for the Debian GNU/Linux operating system, but may be used by others. SEE ALSO
elilo(1) 11 August 2005 EFIBOOTMGR(8)
All times are GMT -4. The time now is 10:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy