more command in Linux with Examples


Advertisements

Name

more - display the text one screenful at a time

Synopsis

more [options] file...

Options

-d
   Prompt  with "[Press space to continue, 'q' to quit.]", and display "[Press 'h' for instructions.]" instead of ringing the bell when an illegal key is pressed.
-l
   Do not pause after any line containing a ^L (form feed).
-f
   Count logical lines, rather than screen lines (i.e., long lines are not folded).
-p
   Do not scroll. Instead, clear the whole screen and then display the text. Notice that this option is switched on automatically if the executable is named page.
-c
   Do not scroll. Instead, paint each screen from the top, clearing the remainder of each line as it is displayed.
-s
   Squeeze multiple blank lines into one.
-u
   Suppress underlining.
-number
   The screen size to use, in number of lines.
+number
   Start displaying each file at line number.
+/string
   The  string  to be searched in each file before starting to display it.
--help
   Display help text and exit.
-V, --version
   Display version information and exit.

Description

more is a command to view (but not modify) the contents of a text file one screen at a time. Programs of this sort are called pagers. more is a very basic pager. Which means, it is an application that allows to navigate a file page-by-page. Originally it allowed only forward navigation through a file. Newer implementations of more do allow for limited backward navigation.

Once more has obtained input, it displays as much as can fit on the current screen and waits for user input to advance, with the exception that a form feed (^L) will also cause more to wait at that line, regardless of the amount of text on the screen. In the lower-left corner of the screen is displayed the text "--More--" and a percentage, representing the percent of the file that more has paged through. (This percentage includes the text displayed on the current screen.) When more reaches the end of a file (100%) it exits. The most common methods of navigating through a file are Enter key, which advances the output by one line, and Space key, which advances the output by one screen.

Interactive Commands

more accepts interactive commands that are based on vi(1). Some commands may be preceded by a decimal number, called k in the descriptions below. In the following descriptions, ^X means control-X. more accepts following interactive commands:

  • Enter key : To scroll down page line by line.
  • Space bar : To go to next page. Displays next k lines of text which defaults to screen size.
  • d or ^D : To scroll k lines of text forward. Defaults to 11 lines.
  • b or ^B : To skip backwards k screenfuls of text. Defaults to 1. This option only works in case of files, not pipes.
  • s : Skip forward k lines of text. Defaults to 1.
  • /pattern : Lets you search for kth occurrence of regular expression. Defaults to 1.
  • n : Search for kth occurrence of last regular expression. Defaults to 1.
  • ' : Go to the place where the last search started.
  • = : Display the current line number.
  • !command or :!command : Execute command in a subshell.
  • ^L : Redraw screen.
  • :n : Go to kth next file. Defaults to 1.
  • :p : Go to kth previous file. Defaults to 1.
  • :f : Display current file name and line number.
  • . : Repeat previous command.

Examples

In order to help the user to navigate use -d option with more command.

$  more -d Story.txt 
The youngest of 13 surviving children, Tagore (nicknamed "Rabi") was born Robindronath Thakur[15] on 7 May 1861 in the Jorasanko mansion
in Calcutta, the son of Debendranath Tagore (1817–1905) and Sarada Devi (1830–1875). Black-and-white photograph of a finely dressed man 
and woman: the man, smiling, stands with the hand on the hip and elbow turned outward with a shawl draped over his shoulders and in Bengali
formal wear. In front of him, the woman, seated, is in elaborate dress and shawl; she leans against a carved table supporting a vase and 
flowing leaves.Tagore and his wife Mrinalini Devi, 1883.
Tagore was raised mostly by servants; his mother had died in his early childhood and his father travelled widely. The Tagore family was at the
forefront of the Bengal renaissance. They hosted the publication of literary magazines; theatre and recitals of Bengali and Western classical 
music featured there regularly. Tagore's father invited several professional Dhrupad musicians to stay in the house and teach Indian classical 
music to the children. Tagore's oldest brother Dwijendranath was a philosopher and poet. Another brother, Satyendranath, was the first Indian 
appointed to the elite and formerly all-European Indian Civil Service. Yet another brother, Jyotirindranath, was a musician, composer, and 
playwright. His sister Swarnakumari became a novelist. Jyotirindranath's wife Kadambari Devi, slightly older than Tagore, was a dear friend and
powerful influence. Her abrupt suicide in 1884, soon after he married, left him profoundly distraught for years.
Tagore largely avoided classroom schooling and preferred to roam the manor or nearby Bolpur and Panihati, which the family visited. His brother 
Hemendranath tutored and physically conditioned him—by having him swim the Ganges or trek through hills, by gymnastics, and by practising judo 
and wrestling. He learned drawing, anatomy, geography and history, literature, mathematics, Sanskrit, and English—his least favourite subject. 
Tagore loathed formal education—his scholarly travails at the local Presidency College spanned a single day. 
--More--(97%)[Press space to continue, 'q' to quit.]

Look at the above snapshot, in the left corner it shows 97%, which indicates that 97% page is displayed.

If we don't want to wrap(fold) the lines and display them as such, use -f option.

$  more -f Story.txt 
The youngest of 13 surviving children, Tagore (nicknamed "Rabi") was born Robindronath Thakur on 7 May 1861 in the Jorasanko mansion in Calcu
tta, the son of Debendranath Tagore (1817–1905) and Sarada Devi (1830–1875).Black-and-white photograph of a finely dressed man and woman: the
man, smiling, stands with the hand on the hip and elbow turned outward with a shawl draped over his shoulders and in Bengali formal wear. In 
front of him, the woman, seated, is in elaborate dress and shawl; she leans against a carved table supporting a vase and flowing leaves. Tago
re and his wife Mrinalini Devi, 1883
Tagore was raised mostly by servants; his mother had died in his early childhood and his father travelled widely.[22] The Tagore family was at
the forefront of the Bengal renaissance. They hosted the publication of literary magazines; theatre and recitals of Bengali and Western classi
cal music featured there regularly. Tagore's father invited several professional Dhrupad musicians to stay in the house and teach Indian class
ical music to the children.[23] Tagore's oldest brother Dwijendranath was a philosopher and poet. Another brother, Satyendranath, was the firs
t Indian appointed to the elite and formerly all-European Indian Civil Service. Yet another brother, Jyotirindranath, was a musician, composer,
and playwright.[24] His sister Swarnakumari became a novelist.[25] Jyotirindranath's wife Kadambari Devi, slightly older than Tagore, was a dea
r friend and powerful influence. 
Her abrupt suicide in 1884, soon after he married, left him profoundly distraught for years. Tagore largely avoided classroom schooling and pre
ferred to roam the manor or nearby Bolpur and Panihati, which the family visited.[27][28] His brother Hemendranath tutored and physically condi
tioned him—by having him swim the Ganges or trek through hills, by gymnastics, and by practising judo and wrestling. He learned drawing, anatom
y, geography and history, literature, mathematics, Sanskrit, and English—his least favourite subject.[29] Tagore loathed formal education—his s
cholarly travails at the local Presidency College spanned a single day. Years later he held that proper teaching does not explain things; proper 
teaching stokes curiosity:
--More--(86%)

more command clears the screen and then displays the text.

$  more -p Story.txt
Tagore largely avoided classroom schooling and preferred to roam the manor or nearby Bolpur and Panihati, which the family visited.[27][28] His brothe
r Hemendranath tutored and physically conditioned him—by having him swim the Ganges or trek through hills, by gymnastics, and by practising judo and w
restling. He learned drawing, anatomy, geography and history, literature, mathematics, Sanskrit, and English—his least favourite subject.[29] Tagore l
oathed formal education—his scholarly travails at the local Presidency College spanned a single day. Years later he held that proper teaching does not
explain things; proper teaching stokes curiosity:[30]
After his upanayan (coming-of-age rite) at age eleven, Tagore and his father left Calcutta in February 1873 to tour India for several months, visiting
his father's Santiniketan estate and Amritsar before reaching the Himalayan hill station of Dalhousie. There Tagore read biographies, studied history
, astronomy, modern science, and Sanskrit, and examined the classical poetry of Kālidāsa.[31][32] During his 1-month stay at Amritsar in 1873 he was g
reatly influenced by melodious gurbani and nanak bani being sung at Golden Temple for which both father and son were regular visitors. He mentions abo
ut this in his My Reminiscences (1912)
--More--(97%)

The golden temple of Amritsar comes back to me like a dream. Many a morning have I accompanied my father to this Gurudarbar of the Sikhs in the mi
ddle of the lake. There the sacred chanting resounds continually. My father, seated amidst the throng of worshippers, would sometimes add his voice to
the hymn of praise, and finding a stranger joining in their devotions they would wax enthusiastically cordial, and we would return loaded with the sa
nctified offerings of sugar crystals and other sweets.[33]
He wrote 6 poems relating to Sikhism and a number of articles in Bengali child magazine about Sikhism.[34]
Tagore returned to Jorosanko and completed a set of major works by 1877, one of them a long poem in the Maithili style of Vidyapati. As a joke, he cla
imed that these were the lost works of newly discovered 17th-century Vaiṣṇava poet Bhānusiṃha.[35] Regional experts accepted them as the lost works of
the fictitious poet.[36] He debuted in the short-story genre in Bengali with "Bhikharini" ("The Beggar Woman").[37][38] Published in the same year, S
andhya Sangit (1882) includes the poem "Nirjharer Swapnabhanga" ("The Rousing of the Waterfall"). 

To view the contents of multiple files using more, pass the names of the files or a pattern to the more command. This will open a buffer for each file and show the first file. A banner is shown to indicate the file being shown.

$  more Story.txt test2.txt 
::::::::::::::
Story.txt
::::::::::::::
The youngest of 13 surviving children, Tagore (nicknamed "Rabi") was born Robindronath Thakur[15] on 7 May 1861 in the Jorasanko mansion in Calcutta,[
16] the son of Debendranath Tagore (1817–1905) and Sarada Devi (1830–1875).[c]
Black-and-white photograph of a finely dressed man and woman: the man, smiling, stands with the hand on the hip and elbow turned outward with a shawl 
draped over his shoulders and in Bengali formal wear. In front of him, the woman, seated, is in elaborate dress and shawl; she leans against a carved 
table supporting a vase and flowing leaves.
Tagore and his wife Mrinalini Devi, 1883
--More--(46%)

To move to the next file press :n. This moves the viewer to the start of the next file. To move back a file press :p. This moves to the start of the previous file.

$  more Story.txt test2.txt
table supporting a vase and flowing leaves.
Tagore and his wife Mrinalini Devi, 1883
...Skipping 
...Skipping to file test2.txt

::::::::::::::
test2.txt
::::::::::::::
a) a.k. shukla
b) anat hari
c) barun kumar
d) jai sharma
--More--(23%)

We can view a file with more command from any specific line number, by passing the + option along with a line number.

$ more +20 Story.txt

The more viewer will open at line 20.

We can open a file at the first occurrence of a search string by passing the + option followed by a search pattern. The search pattern should begin with a '/' and can be a regular expression.The pager will move to the first occurrence of the search pattern.

$ more +/mother Story.txt
...skipping
Tagore and his wife Mrinalini Devi, 1883

Tagore was raised mostly by servants; his mother had died in his early childhood and his father travelled widely.[22] The Tagore family was at the for
efront of the Bengal renaissance. They hosted the publication of literary magazines; theatre and recitals of Bengali and Western classical music featured there regularly. Tagore's father invited several professional Dhrupad musicians to stay in the house and teach Indian classical music to the children.[23] Tagore's oldest brother Dwijendranath was a philosopher and poet. Another brother, Satyendranath, was the first Indian appointed to the elite
and formerly all-European Indian Civil Service. Yet another brother, Jyotirindranath, was a musician, composer, and playwright.[24] His sister Swarna kumari became a novelist.[25] Jyotirindranath's wife Kadambari Devi, slightly older than Tagore, was a dear friend and powerful influence. Her abrupt 
suicide in 1884, soon after he married, left him profoundly distraught for years.
Advertisements