0
0
Linux CLIscripting~20 mins

less and more (paginated viewing) in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Pager Pro
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Output of 'less' command with a specific key press
You run less on a text file with 100 lines. After opening, you press the spacebar key once. What happens?
Linux CLI
less sample.txt
AThe display moves forward by one line only.
BThe display moves forward by one full screen of lines.
CThe display moves backward by one full screen of lines.
DThe display exits immediately.
Attempts:
2 left
💡 Hint
Think about how 'less' paginates content and what the spacebar does.
💻 Command Output
intermediate
2:00remaining
Behavior of 'more' when reaching end of file
You use the command more sample.txt to view a file. When you reach the end of the file, what does 'more' do?
Linux CLI
more sample.txt
AIt automatically exits and returns to the shell prompt.
BIt waits for user input to scroll further even though no more lines exist.
CIt loops back to the start of the file.
DIt displays an error message and exits.
Attempts:
2 left
💡 Hint
Consider what happens when you reach the end of content in pagers.
📝 Syntax
advanced
2:00remaining
Correct command to search forward in 'less'
Which command inside 'less' allows you to search forward for the word 'error'?
Linux CLI
less /var/log/syslog
A?error
B#error
C:error
D/error
Attempts:
2 left
💡 Hint
Think about how forward and backward searches differ in 'less'.
💻 Command Output
advanced
2:00remaining
Output of 'more' with piped input
You run the command cat file.txt | more. What is the behavior of 'more' in this case?
Linux CLI
cat file.txt | more
A'more' ignores the input and exits immediately.
B'more' outputs the entire content without pagination.
C'more' paginates the output, allowing scrolling page by page.
D'more' waits for a filename argument and shows an error.
Attempts:
2 left
💡 Hint
Consider how 'more' handles standard input from pipes.
🚀 Application
expert
3:00remaining
Combining 'less' with environment variable for default options
You want 'less' to always start with line numbers shown and ignore case in searches. Which environment variable setting achieves this?
Aexport LESS='-N -i'
Bexport LESS='-n -I'
Cexport LESS='-N -I'
Dexport LESS='-n -i'
Attempts:
2 left
💡 Hint
Check 'less' man page for option meanings: -N shows line numbers, -i ignores case.