07-06-2011
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 moon'
i need to get the value as 2 and store it in a variable for manipulation.
how to do this ?
Thanks in advance for the help.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
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
2. Shell Programming and Scripting
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
3. Shell Programming and Scripting
Hi Everybody,
I am trying to write a script that will get some perticuler data from a file and redirect to a file.
My Question is,
I have a Very huge file,In that file I have my required data is started from 25th line and it will ends in 100th line.
I know the line numbers, I need to get all... (9 Replies)
Discussion started by: Anji
9 Replies
4. Shell Programming and Scripting
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
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... (7 Replies)
Discussion started by: hcclnoodles
7 Replies
5. Shell Programming and Scripting
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. Shell Programming and Scripting
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
7. UNIX for Dummies Questions & Answers
Hello Everyone.
I am trying to display contains of a file from a specific line to a specific line(let say, from line number 3 to line number 5). For this I got the shell script as shown below:
if ; then
if ; then
tail +$1 $3 | head -n $2
else
... (5 Replies)
Discussion started by: grc
5 Replies
8. Shell Programming and Scripting
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
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
10. Shell Programming and Scripting
Good morning,
My first time actually posting in this forum, though I have used this forum to help with numerous projects.
I am trying to figure out why my if statement does not work. I have a file where a line is inputted every 15 seconds. I want this if statement to check what the last line... (3 Replies)
Discussion started by: Shanrunt
3 Replies
LEARN ABOUT DEBIAN
wmmoonclock
WMMOONCLOCK(1) General Commands Manual WMMOONCLOCK(1)
NAME
WMMOONCLOCK - Dockable Moon Phase Clock
SYNOPSIS
wmMoonClock [-display <Display>] [-bc <Color>] [-lc <Color>] [-dc <Color>] [-low] [-lat <Latitude>] [-lon <Longitude>] [-h]
DESCRIPTION
wmMoonClock displays the current phase of the moon. Clicking on the icon brings up different displays -- there are 5 in all. The different
"pages" are;
First Page
Shows the Moon phase image.
Second Page
Shows the current Local Time (LT) and Universal Time (UT), the Moon's Age (number of days since last new moon), the geometric (as
opposed to temporal) fraction of the way through the current lunar cyle (e.g. 50 for full moon), the fraction of the Moon's disc
that is illuminated (ratio of area illuminated to total area of disc) and whether the Moon is (locally) visible of not (i.e. is it
above the horizon?).
Third Page
Shows the Rise and Set times for yesterday (first line), today (middle line), and tommorrow (last line). If the Moon does not rise
or set on a given day a `null time' is shown (--:--). Note that these times should still be good for high latitude observers. Also
note that there will always be at least one (--:--) showing up per month. This is because once per month the Moon will rise (set) on
a given day but will set (rise) in the very early portion of the next day.
Fourth Page
Shows the Moon's horizon coordinates (i.e. the Altitude/Azimuth system). Azimuth is measured in degrees CCW from due south, and
altitude is measured in degrees from the horizon up to the Moon. Distance (Dist) is measured in units on Earth radii (1 Re is about
6370km). Note that this is a local coordinate system and will not be correct if the observer's latitude and longitude are not set
correctly.
Fifth Page
Shows the Moon's ecliptic coordinates. (i.e. the Right Ascention/Declination system). Useful for astronomers?
Many of the quantities shown will not be correct unless LT and UT are correct, and the user specifies the proper latitude and longitude.
OPTIONS
-display <display>
Use an alternate X Display.
-bc Set background color. (E.g. #7e9e69 or blue)
-lc Set color of text labels.
-dc Set color of data values.
-low Conserve colors. For 8-bit displays, a lower-color pixmap will be used automatically, but you can also force its use on higher-color
displays if necessary.
-lat <Latitude>
Observers Latitude in degrees. Positive in northern hemisphere, negative in southern hemisphere.
-lon <Longitude>
Observers Longitude in degrees. Greenwich is 0.0, and longitude increases positively toward the west. (Alternatively, negative num-
bers can also be used to specify longitudes to the east of Greenwich).
-h Display list of command-line options.
BUGS
Who knows? (Let me know if you find any).
AUTHOR
Michael G. Henderson <mghenderson@lanl.gov>
21 December 1998 WMMOONCLOCK(1)