I can split one large mp3 file into several files based on silence using the mp3split command / program below
mp3splt -f -t 4.0 -a -d split audio_file.mp3
and I get
split/audio_file_000m_00s_005m_00s.mp3
but how can I get
split/000m_00s_005m_00s_audio_file.mp3
or increment by one in the front
split/000_audio_file_000m_00s_005m_00s.mp3
split/001_audio_file_005m_00s_010m_00s.mp3
I looked at the syntax http://wiki.librivox.org/index.php/How_To_Split_With_Mp3Splt but couldn't figure out what needs to change in my syntax.
I'm using ubuntu 16.04 64bit linux
You need to set the -o (output format) option.
Try something like:
mp3splt -o #N3_#f -f -t 4.0 -a -d split audio_file.mp3
Giving you:
001_audio_file.mp3,
002_audio_file.mp3,
003_audio_file.mp3…
The man page is a little messy, but it's all there.
I used
mp3splt -o #N3_#mm_#ss_#f -f -t 4.0 -a -d split audio_file.mp3
which gives me
/split/001_000m_00s_audio_file.mp3
/split/002_004m_00s_audio_file.mp3
Related
I want to use ncap2 to make a large number of variables a function of time in a netcdf file. I therefore wanted to build up the command argument in a loop and store in a bash variable command and then apply it as a variable, which I often do with cdo like this
cdo $command in.nc out.nc
I build up my command like this:
varlist="hfls hfss prlr prw rlds rlus rlut rsds rsdt rsus rsut clt evspsbl"
command=""
for var in $varlist ; do
command+=" -s '${var}[time,lat,lon]=${var}'"
done
echo $command
when I then attempt to do this :
ncap2 $command in.nc out.nc
I get a segmentation fault and core dump. But if I cut and paste the result of the echo command into the ncap2 statement,
ncap2 -s 'hfls[time,lat,lon]=hfls' -s 'hfss[time,lat,lon]=hfss' -s 'prlr[time,lat,lon]=prlr' -s 'prw[time,lat,lon]=prw' -s 'rlds[time,lat,lon]=rlds' -s 'rlus[time,lat,lon]=rlus' -s 'rlut[time,lat,lon]=rlut' -s 'rsds[time,lat,lon]=rsds' -s 'rsdt[time,lat,lon]=rsdt' -s 'rsus[time,lat,lon]=rsus' -s 'rsut[time,lat,lon]=rsut' -s 'clt[time,lat,lon]=clt' -s 'evspsbl[time,lat,lon]=evspsbl' $dir/$file /scratch/b/$USER/${file%???}_corrected.nc
It works fine... I'm sure it is something to do with the way I'm handling the strings, but my experiments trying to change around quotes etc, didn't seem to work.
Yes, it seems to be a shell-quoting issue.
Rather than try to create a simpler analogue for testing, let me start by just asking, does it work if you use this instead?
eval ncap2 $command in.nc out.nc
I often find Bash syntax very helpful, e.g. process substitution like in diff <(sort file1) <(sort file2).
Is it possible to use such Bash commands in a Makefile? I'm thinking of something like this:
file-differences:
diff <(sort file1) <(sort file2) > $#
In my GNU Make 3.80 this will give an error since it uses the shell instead of bash to execute the commands.
From the GNU Make documentation,
5.3.2 Choosing the Shell
------------------------
The program used as the shell is taken from the variable `SHELL'. If
this variable is not set in your makefile, the program `/bin/sh' is
used as the shell.
So put SHELL := /bin/bash at the top of your makefile, and you should be good to go.
BTW: You can also do this for one target, at least for GNU Make. Each target can have its own variable assignments, like this:
all: a b
a:
#echo "a is $$0"
b: SHELL:=/bin/bash # HERE: this is setting the shell for b only
b:
#echo "b is $$0"
That'll print:
a is /bin/sh
b is /bin/bash
See "Target-specific Variable Values" in the documentation for more details. That line can go anywhere in the Makefile, it doesn't have to be immediately before the target.
You can call bash directly, use the -c flag:
bash -c "diff <(sort file1) <(sort file2) > $#"
Of course, you may not be able to redirect to the variable $#, but when I tried to do this, I got -bash: $#: ambiguous redirect as an error message, so you may want to look into that before you get too into this (though I'm using bash 3.2.something, so maybe yours works differently).
One way that also works is putting it this way in the first line of the your target:
your-target: $(eval SHELL:=/bin/bash)
#echo "here shell is $$0"
If portability is important you may not want to depend on a specific shell in your Makefile. Not all environments have bash available.
You can call bash directly within your Makefile instead of using the default shell:
bash -c "ls -al"
instead of:
ls -al
There is a way to do this without explicitly setting your SHELL variable to point to bash. This can be useful if you have many makefiles since SHELL isn't inherited by subsequent makefiles or taken from the environment. You also need to be sure that anyone who compiles your code configures their system this way.
If you run sudo dpkg-reconfigure dash and answer 'no' to the prompt, your system will not use dash as the default shell. It will then point to bash (at least in Ubuntu). Note that using dash as your system shell is a bit more efficient though.
It's not a direct answer to the question, makeit is limited Makefile replacement with bash syntax and it can be useful in some cases (I'm the author)
rules can be defined as bash-functions
auto-completion feature
Basic idea is to have while loop in the end of the script:
while [ $# != 0 ]; do
if [ "$(type -t $1)" == 'function' ]; then
$1
else
exit 1
fi
shift
done
https://asciinema.org/a/435159
im trying to print the content of a html table cell.
i thought the easiest way to do this was with grep,
but for some reason the regex works on regexr.com but not within Grep.
Maybe something with escaping? i tried escaping al the smaller and larger than <> symbols.
This is the code i'm using
wget -q -O login.html --save-cookies cookies.txt --keep-session-cookies --post-data 'username=sssss&password=fffff' http://ffffff/login
wget -q -O page.html --load-cookies cookies.txt http://ffffff/somepage |grep -P '(?<=<tr><td class=list2>www</td><td class=list2 align=center>A</td><td class=list2 >)(.*?)(?=</td><td class=list2 align=center><input type=checkbox name=arecs5)' |recode html...ascii
Can anybody help me please? I'm from the netherlands so sorry for my english.
i aslo tried adding the -c option and it printed 0
EDIT:
Added my full code, i found 1 mistake. i didn't have the -O parameter to output the page's html. but it still doesnt work. it prints nothing
Traditional grep doesn't support lookarounds the way you're using it.
Try using grep -P (PCRE):
grep -P 'pattern' file
Consider using Ack or ag that supports natively PCRE.
Finally, it works.
I added -qO- to wget, i don't know why but when adding a - after the -O it works.
When I directly run a command in my Linux terminal, say "ls", the output is with color. However, when I run a C++ program which calls system("ls"), the output does not have color.
Is there way to get the latter way to also display colored output?
Thanks!
The answer for why there's no color lies here.
system() executes a command specified in command by calling /bin/sh -c
command, and returns after the command has been completed.
sh -c ignores aliases. Perhaps somewhere you have an alias where ls means ls --color=auto.
So for example, if I do sh -c 'ls', I will get no color.
Proof:
wow ♪[01:04 AM][vnbraun#chernobyl ~]$ which ls
alias ls='ls --color=auto'
/bin/ls
wow ♪[01:08 AM][vnbraun#chernobyl ~]$ sh -c 'which ls'
/bin/ls
Therefore, you can try doing system("ls --color=auto");.
You could run
system("/bin/ls --color=auto");
But I don't think you really should run ls from your C++ program. Perhaps you want to use -some combination of- readdir(3), stat(2), nftw(3), glob(3), wordexp(3) etc etc....
I don't think that forking a shell which then runs /bin/ls is useful from a C++ program. There are simpler ways to achieve your goal (which I cannot guess).
You probably should read Advanced Linux Programming
Try invoking ls --color=auto or ls --color=always to display ls with colors.
This is likely due to a bash configuration file somewhere in your system aliasing "ls" to "ls --color".
Using "ls --color" in your program should work.
I am currently using freearc, precomp042 and srep 3.2
I use 4 regular compressions styles as noted below depending on data type and have no problem. I recently tried using srep 3.9, 3.91 and 3.92. All compress OK but fail immediately on decompression with an srep l256 error
What can I change to allow the new version to work and is it possible to improve compression. I have 8gb RAM and compression time is not a problem for me
Many thanks
arc a -ep1 -ed -r -w Archive(A1).bin -mx -mc-delta -mc:lzma/lzma:192mb:normal:bt4:192:mc10000:lc8 -ld192m -mc:rep/srep:l256 -mc$default,$obj:+precomp042:c-:t-j:intense -s -x Archive\*.*
arc a -ep1 -ed -r -w Archive(A2).bin -mx -mc:lzma/lzma:max:512mb -mc:exe/exe2 -mc:rep/maxsrep -mc$default,$obj:+maxprecompj -x Archive\*.*
arc a -ep1 -ed -r -w Archive(A3).arc -msrep+lzma:a1:mfbt4:d256m:fb128:mc1000:lc8 -x Archive\*.*
arc a -ep1 -ed -r -w Archive(A4).bin -mprecomp:zl69:d0:t-jnf+srep+lzma:a1:mfbt4:d256m:fb128:mc1000:lc8 -x Archive\*.*
Here mate, try this. Its the most powerful compression without messing around many external compressors.
-mprecomp+srep:m3f:a1:l256+lzma:a1:mfbt4:d200m:fb128:mc1000:lc8