m1gin 360

EditWithShell: Run Command

Beware of hidden characters when copying from this web page.

Samples:

  • abc=$(xargs -I {} echo {}); [[ "$abc" == "10" ]] && echo "==$abc" || echo "hey"
  • xargs -I {} python3 "/home/m1/Documents/python/learn-python/mblib/individual/vscode_editwithshell.py" -get_def {}


Check the selected youtube video id if it is available.

  • xargs -I {} python3 "/home/mb/dev/python/mblib/individual/vscode_editwithshell.py" -check_yt_video {}
  • abc=$(xargs -I {} curl "https://www.youtube.com/oembed?url=http://www.youtube.com/watch?v={}&format=json"); [[ "$abc" == "Not Found" ]] && echo "[NA]" || echo "$abc" | jq '.type'
  • xargs -I {} python3 "/home/mb/dev/python/mblib/individual/vscode_editwithshell.py" -get_yt_video_title {}

convert text to speech and save it as file and get filename:

  • prm=$(xargs -I {} echo {}); f=$(date +%s%N); espeak -v en+whisperf "$prm" -w $f.wav; echo "${PWD}/$f.wav";
  • prm=$(xargs -I {} echo {}); f=$(date +%s%N); google_speech -l en "$prm" -o $f.mp3; echo "${PWD}/$f.mp3";
  • xargs -I {} espeak -v tr+whisperf {} -w $(date +%s).wav; echo $(date +%s);

For text contains single quote ' xargs doesn't work correctly even though xargs -0 -null parameters used.

After long search, I overcame the problem using parallel

  • parallel -j0 -C '\t' 'prm1=`echo {1}`' ";" 'prm2=`echo {2}`' ";" espeak -v en+f5 '"$prm1"' -w '"$prm2.wav"' ";" echo '"${PWD}/$prm2.wav"'
  • parallel -j0 -C '\t' 'prm1=`echo {1}`' ";" 'prm2=`echo {2}`' ";" google_speech -l en '"$prm1"' -o '"prm2.mp3"' ";" echo '"${PWD}/$prm2.mp3"'


Add to: