0

This shows the last saved screenshot (on my Desktop path):

 ls -t | head -n1

This prints perfectly:

 lp -o -scaling=50 -o media=Custom.60x42mm -o page-left=0 -o page-right=0 -o page-top=5 -o page-bottom=5 image.png

How does one combine them?

Without really knowing what I'm doing I've tried this:

ls -t | head -n1 |awk '{lp -o -scaling=50 -o media=Custom.60x42mm -o page-left=0 -o page-right=0 -o page-top=5 -o page-bottom=5  $0}'

which, naturally fails:

error

Guy
  • 12,488
  • 16
  • 79
  • 119

2 Answers2

1
lp -o -scaling=50 -o media=Custom.60x42mm -o page-left=0 -o page-right=0 -o page-top=5 -o page-bottom=5  "$(ls -t | head -n1)"

Or more clear:

filetouse="$(ls -t | head -n1)"
lpoptions=( -o -scaling=50 -o media=Custom.60x42mm -o page-left=0 -o page-right=0 -o page-top=5 -o page-bottom=5 )

lp "${lpoptions[@]}" "${filetouse}"
0

Ok, just managed to do it. This worked:

ls -t | head -n1 | xargs -I {} lp -o -scaling=50 -o media=Custom.60x42mm -o page-left=0 -o page-right=0 -o page-top=5 -o page-bottom=5 {}

Thanks to this question.

Community
  • 1
  • 1
Guy
  • 12,488
  • 16
  • 79
  • 119