Sponsored Content
Top Forums Shell Programming and Scripting finding the line number from a grep ? Post 302293382 by hcclnoodles on Tuesday 3rd of March 2009 04:04:23 AM
Old 03-03-2009
finding the line number from a grep ?

Hi there

does anybody know how i can get the line number from an entry or entries in a file ?? for example if i had a file


Code:
test1
test2
test3
test1


and i needed to get the line numbers for all instances of test1 in that file

with the answer being (1,4)


Would anybody be able to point me in the right direction with this ..?

Any help would be greatly appreciated
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding number ranges using grep

Is it possible for me to find numbers in a file by a range using grep? like cat data | cut -f1 | grep <info> Im trying to find information and extract every amount that is less than a number (ie less than 75 or whatever) Is this possible? (2 Replies)
Discussion started by: DKNUCKLES
2 Replies

2. Shell Programming and Scripting

Finding the line number of matching braces

Hi,I am new to shell scripting and i want to find the line numbers of matching braces. The file contents are as follows File XXX.dat 1 ( CLASS "FRUIT" 2 (TYPE "PERSISTENT") 3 (MESSAGE_TYPE "M") 4 (GET_REQRD "Y") 5 (SET_REQRD "Y") 6 ) 7 ( CLASS... (3 Replies)
Discussion started by: Rajendra_1510
3 Replies

3. Shell Programming and Scripting

awk or sed for finding closest pattern to a line number

hi guys, I want to do pattern matching with awk or sed but I don't know how. here's what I want: I have a line number for a pattern that I have already found using grep, and I know a pattern like "---" that happens a few lines above that certain line number. I want to print out the chunk... (1 Reply)
Discussion started by: alirezan
1 Replies

4. Shell Programming and Scripting

finding line number if the line contains

hi i have a file , that contains data like 34343538 3136414D 45583030 30302E54 445816AMEX0000.T 524E2020 20202020 20202020 20202020 RN 20202020 20203030 38303030 30303030 0080000000 30303030 30300D 000000. 20080724-051254.668419 D 473... (1 Reply)
Discussion started by: Satyak
1 Replies

5. Shell Programming and Scripting

finding the number of occurence of a word in a line

suppose i have this line abs|der|gt|dftnrk|dtre i want to count the number of "|" in this line.. how can i do that. plz help:confused: (9 Replies)
Discussion started by: priyanka3006
9 Replies

6. UNIX for Dummies Questions & Answers

grep question: stop search from finding entire line

Sorry for the title, I really don't know how to word this question or what to even search for. I tried "grep one match", "grep 1 match", "stop grep" on both google and here and haven't found something that helps, so here I go: I have a file that's about 1.5 million lines long, every line looks... (3 Replies)
Discussion started by: rmoakler
3 Replies

7. 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

8. Shell Programming and Scripting

Finding the line with the exact same number

Hello All, What i am doing is , i tail a file from certain chatacter and then cat -n to get the line numbers.I search for a particular string and gets it line number. What i am interested in is the next line immediately after the pattern i search. But grep gives me result for all line... (5 Replies)
Discussion started by: kailash19
5 Replies

9. Shell Programming and Scripting

finding the line number of a particular line in a file

Hi Frnds, I need to find the line number of a particular line in a file and store that line number to a variable. if a file named myfile contains following look at the sun look at the moon look at the star look at the ocean i need to get the line number of the line 'look at the... (3 Replies)
Discussion started by: mvignesh
3 Replies

10. Shell Programming and Scripting

help for fast way of finding line number for a regex

Hello, I am trying to find out the line numbers where regex match and put them into a file with below command: awk '/'$pat'/ {print NR}' $fileName >> temp.txt where $pat is the regex but this command is taking a lot of time to execute with bigger files for size more than 5000000... (8 Replies)
Discussion started by: JoeColeEPL9
8 Replies
music123(1)						      General Commands Manual						       music123(1)

NAME
music123 - plays various sound files (usually including MP3, Ogg and Wav). SYNOPSIS
music123 [ -hqrvz ] file ... DESCRIPTION
music123 is a shell around various command line programs to play music files. It will descend directories trees with -r, and randomize file lists with -z. The programs used and the options given them are listed in /etc/music123rc or ~/.music123rc. OPTIONS
-h Show command help and exit; -q Quiet mode. No messages are displayed. -r Recurse into directories, instead of ignoring them. -v Display version information and exit. -z Play files in random order. -Z Play the files randomly and endlessly. -l Loop. -z -l differs from -Z in that -z -l will randomize, play through the song list (without repetition) in random order once, and repeat the songs in that order over and over; -Z will randomly play the songs, without any order, and will possibly play a song right after itself. -i Ignore extension case. -L List files and exit. -T Start a task that handle commands, only one command supported : quit, using q or Q will quit the application at the end of the cur- rent song. -D Set music123 not to delay between songs. (May make music123 harder to kill). -d Customize the time music123 delays between songs. -d takes one argument, expressed in seconds, which may have a fractional part. -@ Play the files listed in the mandatory argument of -@. Other files can be added on the command line, and this option can be given several times. Note that music123 doesn't yet play URLs. -- End option list. EXAMPLES
Play three songs: music123 test1.ogg test2.mp3 test3.wav Play a couple of directories and other songs at random: music123 -z -r Rock/ test1.ogg Pop/ test4.wav FILES
/etc/music123rc Describes which programs music123 uses, which files types it supports, and which options it passes those programs. ~/.music123rc Per-user config file to override the system wide settings. AUTHORS
Authors: David Starner <dvdeug@debian.org> July 24, 2002 music123(1)
All times are GMT -4. The time now is 06:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy