manipulate files with whitespace in xargs

create an example scenario, files with whitespace in one dir

mkdir /tmp/dir; touch /tmp/dir/{'file 1','file 2','file 3.txt','file 4.txt'}

remove all files of /tmp/dir

find /tmp/dir/ -type f -print0 | xargs -0 rm -f

remove only .txt files of /tmp/dir

find /tmp/dir -name '*.txt' -type f -print0 | xargs -0 rm -f

play all files in current dir ordered by timestamp

find -exec ls -t {} + | xargs -d '\n' mplayer

play only .mp4 files in current dir ordered by timestamp

find -name '*.mp4' -type f -exec ls -t {} + | xargs -d '\n' mplayer

copy all mp3 files containing or not whitespace to /tmp

find -name '*.mp3' -exec ls {} + | xargs -d '\n' -I% cp % /tmp
Advertisements

convert mp3 to low quality

to convert one single mp3 file with bitrate of 96k

ffmpeg -i input.mp3 -b:a 96k output.mp3

convert mp3 changing title of file with bitrate of 56k

ffmpeg -i input.mp3 -b:a 56k -metadata title="abc" output.mp3

to view information about mp3 file

ffmpeg -i file.mp3

one-liner to convert multiple files

for i in $( ls *.mp3 );do ffmpeg -i $i -b:a 56k output_$i; done

prescribe commands kyocera printer

set printer to use PCL 6 emulation mode

echo '!R! FRPO P1, 6; FRPO P3, 1; EXIT;' | lp -d PrinterName -o raw

print barcode with kyocera prescribe command using PCL 6 emulation on linux

echo '!R! UNIT D; BARC 19, Y, "ABC30", 30, 30; EXIT;' | lp -d PrinterName -o raw
echo '!R! UNIT D; BARC 19, N, "ABC90", 90, 90; EXIT;' | lp -d PrinterName -o raw

set resolution to 300dpi

echo '!R! FRPO N8, 0; EXIT;' | lp -d PrinterName -o raw

link to official manual of prescribe
https://cdn.kyostatics.net/dlc/eu/documentation/usermanual/prescribetech_en_40.-downloadcenteritem-Single-File.downloadcenteritem.tmp/PRESCRIBE_COMMA…rence_(ENG).pdf

print using command line linux

To list avaiable printers

lpstat -p

To print a plain text in one printer

echo 'oi' | lp -d printerNameHere

To print a pdf file in one printer

lp -d printerNameHere file.pdf

To print to parallel printer

echo 'oi' > /dev/lp0

To view printer log

tail -f /var/log/cups/page_log

if you print to a pdf printer the files will be saved in: /var/spool/cups-pdf