# show only first line found: grep "search this" nohup.out | sed -n '1p' # show only last line found: grep "search this" nohup.out | sed -n '$p' # copy to current path the file /home/gigi/systemctl-services.txt # from adrhc.go.ro (remote ssh server) using custom ssh port 27 scp -P 27 gigi@adrhc.go.ro:/home/gigi/systemctl-services.txt .