Less or echo

Is there a better way to show the results of a file on the screen other then less , which exits the program and displays:

Input   Status
AB026906.1:c.274G>T     OK
c:/Users/cmccabe/Desktop/Python27/syntax_verify.txt (END) 
authenticate() {
    printf "\n\n"
	less c:/Users/cmccabe/Desktop/Python27/syntax_verify.txt
	printf "Is this correct?  Y/N "; read match_choice

    case "$match_choice" in
        [yY]) id=""; other ;;
        [nN]) rm cd 'C:' c:/Users/cmccabe/Desktop/Python27/syntax_verify.txt; menu ;; 
    esac
} 

Is there a way to

 echo 

the contents of a file on-screen or how do you code it so that after the less is shown the user hits enter to go back to the program? Thank you :).

Try cat , but it has the disadvantage that it doesn't page.

1 Like

If you want to print a string, use echo or printf .

If you want to print the contents of a file, use cat .

If you want to print a file that won't fit on a screen and you want your users to be able to scroll up and down, or to be able to search for strings in the file; use less , more , or view . (Or, give your users an option to choose the viewer they want or an environment variable they can set to choose the viewer they want and select and document the default viewer your program will use if the option or environment variable is not set.)

Anytime you dump a user into an external application (such as a file viewer), tell the user what application you're using. That way, they will know what they have to do to get out of it when they're done. (Or, if they aren't familiar with that application, they can use man application to figure out what they need to do.)

1 Like

This environment variable is likely to already exist.

The PAGER variable, used at least by the "man" command, typically contains "less" or "more".

2 Likes

Thank you :).