I've noticed that on Ubuntu, the "more" and "less" command seem to behave quite differently. I imagine the same is true with other distros, but I know for sure that what I'm about to describe is true with Ubuntu.
When using the "less" command in a shell script, it outputs the text as though it's a separate program, and then once it's done outputting, the script's output goes back to where it left off. It's pretty difficult to explain, so maybe I should just post the code:
#!/bin/bash
if [ ! -d "/tmp/script_test/" ]; then
mkdir "/tmp/script_test/"
fi
for (( i = 1 ; i <= 40 ; i++ ))
do
if [ $i == 1 ]; then
echo "Title 1" > "/tmp/script_test/list_of_titles.txt"
else
echo "Title $i" >> "/tmp/script_test/list_of_titles.txt"
fi
echo " This is a description of Title $i" > "/tmp/script_test/Title $i Description.txt"
done
BYELLOW="\E[1;33;40m"
WHITE="\E[0;37;40m"
function list_display() {
i=1
while read Title
do
echo -e "${BYELLOW}${i}: ${Title}${WHITE}"
if [ -e "/tmp/script_test/$Title Description.txt" ]; then
cat "/tmp/script_test/$Title Description.txt"
fi
i=`expr $i + 1`
done < /tmp/script_test/list_of_titles.txt
}
echo
echo ---
echo "Displaying the list using 'more'..."
echo ---
sleep 2
list_display | more
echo
echo ---
echo "Displaying the list using 'less'..."
echo ---
sleep 2
list_display | less -E -F -r --prompt="Press Space for more or q when done"
--------------------------------------------------
Any help would be appreciated.
Last edited by pludi; 12-05-2009 at 06:29 AM..
Reason: code tags, please...
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address
and column 3 contains “cc” e-mail address to include with same email.
Sample input file, email.txt
Below is an sample code where... (2 Replies)
I am trying to find lines in a text file larger than 3 Gb that start with a given string. My command looks like this:
$ look "string" "/home/patrick/filename.txt"
However, this gives me the following message:
"look: /home/patrick/filename.txt: File too large"
So, I have two... (14 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
Hello,
I am new to this forums and this is my first "asking help" message!
i have 2 problems:
1- for unknown reasons the "source" command is not avalable in my system (UBUNTU). i can't either see it in my bin directory!
2- again for unknown reasons the "login.cl" file in the home... (0 Replies)
Hi,
When typing the command ps -fe.the system is showing a process called SYSCON:confused:....
I am not sure what process is that.I hava a script that kills all command staring with 'sys' but i don't want to kill syscon:( since i think it is some system process:confused:
.Please help me to find... (1 Reply)