The -p option on the command line is equivalent to specifying +/pattern; that is, it tells less to start at the first occurrence of pattern in the file.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
## create a long file with 200 lines > myfile; i=1; while [ $i -le 200 ]; \ do echo "$i" >> myfile; ((i++)); done sed -i "100i hello" myfile ## inserts HELLO on line no. 100 of myfile sed -i "130i hello" myfile ## inserts hello on line no. 130 of myfile ## less -ppattern or --pattern=pattern less -p "hello" myfile ## display start with hello (line no. 100) ## default less myfile ## display start from bigining (line no. 1) rm myfile |