LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-22-2015, 10:31 PM   #1
General
Member
 
Registered: Aug 2005
Distribution: Debian 7
Posts: 526

Rep: Reputation: 31
How to pipe or catch the output of SoX?


I am writing a BASH script that sorts MP3s based on some differences in the audio. I found this command can print out some useful statistics about an MP3:

sox audio.mp3 -n stat

This prints the statistics right into the terminal. I can't seem to find any way to capture these statistics. For example, these don't work:


sox audio.mp3 -n stat > out.txt

sox audio.mp3 -n stat | tail -1

How can I capture or pipe the output of SoX statistics?
 
Old 09-22-2015, 11:22 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 18,238

Rep: Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712
According to the man page, for the stat option, the o/p is passed to stderr (not stdout).
 
Old 09-27-2015, 06:24 PM   #3
robertdaleweir
Member
 
Registered: Jul 2006
Location: Canada
Distribution: Fedora
Posts: 93

Rep: Reputation: 11
Quote:
Originally Posted by General View Post
I am writing a BASH script that sorts MP3s based on some differences in the audio. I found this command can print out some useful statistics about an MP3:

sox audio.mp3 -n stat

This prints the statistics right into the terminal. I can't seem to find any way to capture these statistics. For example, these don't work:


sox audio.mp3 -n stat > out.txt

sox audio.mp3 -n stat | tail -1

How can I capture or pipe the output of SoX statistics?
Hi General
Try
Quote:
sox audio.mp3 -n stat > out.txt 2>&1 | tail -1
.

Last edited by robertdaleweir; 09-27-2015 at 06:27 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Catch exit code before pipe in bash script? prl77 Linux - General 4 05-24-2012 12:09 PM
sox package, Slackware 13.1, fails on sox 1.wav -e stat burbabro Slackware 1 05-04-2011 02:26 AM
howto catch output of bashinstruction Byenary Linux - General 1 06-15-2007 08:48 AM
Sox not exiting when used in a pipe rignes Slackware 3 08-06-2006 06:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration