Sponsored Content
Top Forums Shell Programming and Scripting Displaying lines of a file which have the highest number? Post 302415415 by Glyn_Mo on Thursday 22nd of April 2010 02:03:57 PM
Old 04-22-2010
Scrutinizer, many thanks.

I've had a problem when running this against another file though. The file contents are as follows:

Code:
bash-3.00$ cat release
ins_smo.sql-22                           1
lfa10ins.fmb-1                           1
lfa10ins.fmb-2                           1
lfa10ins.fmx-1                           1
lfa10ins.fmx-1                           2
lfa10ins.fmx-2                           1
lfa10ins.fmx-2                           2
pen_pack_05.pkb-8                        2
pkg_land_insp_capture_form.pkb-19        1
release_note_SAF10_Certification_1.doc-0 1
release_note_SAF10_Certification_1.doc-1 1
release_note_SAF10_Certification_1.doc-2 1
releasenote-1317                         1
saf09127.rdf-10                          1
saf09127.rdf-9                           1
saf09127.rep-10                          1
saf09127.rep-10                          2
saf09127.rep-9                           1
saf09127.rep-9                           2
saf1016c.fmb-1                           1
saf1016c.fmb-2                           1
saf1016c.fmx-1                           1
saf1016c.fmx-1                           2
saf1016c.fmx-2                           1
saf1016c.fmx-2                           2
saf1016m.fmb-1                           1
saf1016m.fmx-1                           1
saf1016m.fmx-1                           2
saf1016s.fmb-1                           1
saf1016s.fmx-1                           1
saf1016s.fmx-1                           2
bash-3.00$

When I run your command, I get the following returned:
Code:
saf09127.rep-9            2
releasenote-1317          1
ins_smo.sql-22            1
saf1016s.fmx-1            1
saf1016c.fmb-2            1
saf1016s.fmx-1            2
saf1016s.fmb-1            1
pen_pack_05.pkb-8         2
saf1016m.fmx-1            1
saf1016m.fmx-1            2
pkg_land_insp_capture_form.pkb-19 1
saf1016m.fmb-1            1
lfa10ins.fmx-2            1
lfa10ins.fmx-2            2
lfa10ins.fmb-2            1
release_note_SAF10_Certification_1.doc-2 1
saf1016c.fmx-2            1
saf1016c.fmx-2            2
saf09127.rdf-9            1
saf09127.rep-9            1

The problem is that objects
Code:
saf09127.rdf-9            1
saf09127.rep-9            1
saf09127.rep-9            2

... are being displayed, instead of
Code:
saf09127.rdf-10            1
saf09127.rep-10            1
saf09127.rep-10            2

Is there some problem when it's calculating double-figures?

I must the awk I'm seeing in these solutions is a bit beyond my current knowledge! Thanks to both. Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find the highest number in the file

Hi, I have a file a.txt and it has values in it Eg :- I need to read through the file and find the number that is the greatest in them all. Can any one assit me on this. Thanks (30 Replies)
Discussion started by: systemali
30 Replies

2. UNIX for Dummies Questions & Answers

Displaying specific lines in a file.

I'm trying to figure out how to display a certain line in a text file. I keep getting references to Tail and Head, and I know how these work, but i'm lost on how to find say the third out of the five lines and display only that. I thought maybe grep could help, but that doesn't seem likely. ... (3 Replies)
Discussion started by: MaestroRage
3 Replies

3. Shell Programming and Scripting

Displaying number of lines from file

Hi, I am using below command to display the number of line, but its returning no of lines along with file name. But i want only no of line in the variable p. Please help me on this? p=`wc -l "text file"` echo "$p" (6 Replies)
Discussion started by: shivanete
6 Replies

4. Shell Programming and Scripting

Displaying lines of a file where the second field matches a pattern

Howdy. I know this is most likely possible using sed or awk or grep, most likely a combination of them together, but how would one go about running a grep like command on a file where you only try to match your pattern to the second field in a line, space delimited? Example: You are... (3 Replies)
Discussion started by: LordJezoX
3 Replies

5. Shell Programming and Scripting

Finding line with highest number in a file

Hi All, My file looks some thing like this, File 1: - A 10 B 30 C 5 D 25 E 72 F 23 now my requirement is to find the line with highest number in it, i;e the result should be E 72 Thanks in Advance (1 Reply)
Discussion started by: balu_puttaganti
1 Replies

6. Homework & Coursework Questions

Displaying specific lines from a CSV file

1. The problem statement, all variables and given/known data: Display from a csv file, birthdays that occur today. If there are no birthdays today, the next one in the year. 2. Relevant commands, code, scripts, algorithms: The csv file is ordered from older to younger (ie. the most recent... (8 Replies)
Discussion started by: Adzi
8 Replies

7. Shell Programming and Scripting

How to only display lines where a field has the highest number?

Hello Wondering if anybody can advise me how I can sort the below file so it only displays lines with the latest versions of an object? As you'll see some of the scripts listed in my file have more than one version number (version number is after the file extension). E.g. cdm_bri.pkb has... (2 Replies)
Discussion started by: Glyn_Mo
2 Replies

8. Shell Programming and Scripting

Bash, finding highest number in another file

i have a problem i am working on and am completely new to bash commands. I writing a script to read another file and output the max and Min number in the script. I must use variables to output the max and min numbers. grades = file with numbers in them. This is what i got so far. Thank You in... (3 Replies)
Discussion started by: ctanner10126
3 Replies

9. Programming

Help with find highest and smallest number in a file with c

Input file: #data_1 AGDG #data_2 ADG #data_3 ASDDG DG #data_4 A Desired result: Highest 7 Slowest 1 code that I try but failed to archive my goal :( #include <stdio.h> (2 Replies)
Discussion started by: cpp_beginner
2 Replies

10. Shell Programming and Scripting

Adding user name to file, and then displaying new line number

Hi all - I'm completely stumped by a script I'm working on... The short version is I have a file called 'lookup' and in it are hundreds of names (first and last). I have a script that basically allows the user to enter a name, and what I need to have happen is something like this: Record... (8 Replies)
Discussion started by: sabster
8 Replies
IRSEND(1)								FSF								 IRSEND(1)

NAME
irsend - basic LIRC program to send infra-red commands SYNOPSIS
irsend [options] DIRECTIVE REMOTE CODE [CODE...] DESCRIPTION
Asks the lircd daemon to send one or more CIR (Consumer Infra-Red) commands. This is intended for remote control of electronic devices such as TV boxes, HiFi sets, etc. DIRECTIVE can be: SEND_ONCE - send CODE [CODE ...] once SEND_START - start repeating CODE SEND_STOP - stop repeating CODE LIST - list configured remote items SET_TRANSMITTERS - set transmitters NUM [NUM ...] SIMULATE - simulate IR event REMOTE is the name of a remote, as described in the lircd configuration file. CODE is the name of a remote control key of REMOTE, as it appears in the lircd configuration file. NUM is the transmitter number of the hardware device. For the LIST DIRECTIVE, REMOTE and/or CODE can be empty: LIST "" "" - list all configured remote names LIST REMOTE "" - list all codes of REMOTE LIST REMOTE CODE - list only CODE of REMOTE The SIMULATE command only works if it has been explicitly enabled in lircd. -h --help display usage summary -v --version display version -d --device use given lircd socket [/var/run/lirc/lircd] -a --address=host[:port] connect to lircd at this address -# --count=n send command n times EXAMPLES
irsend LIST DenonTuner "" irsend SEND_ONCE DenonTuner PROG-SCAN irsend SEND_ONCE OnkyoAmpli VOL-UP VOL-UP VOL-UP VOL-UP irsend SEND_START OnkyoAmpli VOL-DOWN ; sleep 3 irsend SEND_STOP OnkyoAmpli VOL-DOWN irsend SET_TRANSMITTERS 1 irsend SET_TRANSMITTERS 1 3 4 irsend SIMULATE "0000000000000476 00 OK TECHNISAT_ST3004S" FILES
/etc/lirc/lircd.conf Default lircd configuration file. It should contain all the remotes, their infra-red codes and the corresponding timing and wave- form details. DIAGNOSTICS
If lircd is not running (or /var/run/lirc/lircd lacks write permissions) irsend aborts with the following diagnostics: "irsend: could not connect to socket" "irsend: Connection refused" (or "Permission denied"). SEE ALSO
The documentation for lirc is maintained as html pages. They are located under html/ in the documentation directory. lircd(8), mode2(1), smode2(1), xmode2(1), irrecord(1), irw(1), http://www.lirc.org. irsend 0.8.7pre1 May 2010 IRSEND(1)
All times are GMT -4. The time now is 04:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy