Can Diff take arrays as input?
Does diff not like arrays? How do achieve the following?
Code:
stuart@stuart:~/music transfer$ diff file1.txt file2.txt Code:
stuart@stuart:~/music transfer$ echo $x |
Hi.
Some shells allow process substitution where the result of a command is substituted for a file: Code:
#!/usr/bin/env bash Code:
% ./s1 |
Thanks makyo!
My knowledge is too limited to understand everything that is going on here, but I've got the 'bit I wanted' to work on my script. I'll read this again at some stage, once i've a deeper understanding of things. Here's another problem that's driving me mad: Code:
awk NR==$x Musiclist.txt | cut -d/ -f$num | basename $1 .mp3 |
Quote:
Code:
basename $(awk NR==$x Musiclist.txt | cut -d/ -f$num | basename $1 .mp3) Code:
basename `awk NR==$x Musiclist.txt | cut -d/ -f$num | basename $1 .mp3` |
I would add to smeezekitty's reply and say it is probably a waste to pipe all of this when awk more than likely would do all the work.
Just a thought ;) |
I'll have to read up on awk, grail. (so much to learn! :))
Hmm... that code is giving me the same output as before: Code:
stuart@stuart:~/music transfer$ echo $num |
Maybe you would supply a before and after picture so we can help?
ie. are the names of mp3 files the only thing in Musiclist.txt or is there a path as well? i also presume the after is just the name of the song without extension? |
Quote:
Code:
stuart@stuart:~/music transfer$ cat Musiclist.txt |
So I have 2 solutions you can choose from:
One liner: Code:
awk -F"/" '{sub(/\..*/,"",$NF);print $NF}' Musiclist.txt Code:
#!/bin/bash |
Quote:
Why isn't smeezekitty's command working do you think? (This awk command comes up with some frequency, i'm going to have to read into it as some point.) |
Cleanest way is probably:
Code:
awk -F"/" -v line=$x 'NR==line{sub(/\..*/,"",$NF);print $NF}' Musiclist.txt |
Quote:
My program should work now, i'll test it all later today. |
If you're still interested grail, here's the close to finished command (it works, just crude!):
Code:
convert () { mplayer -cache 32 -ao pcm:file="${file[x]}".wav "${file[x]}".mp3; lame -V2 "${file[x]}".wav "${file[x]}".flac; } ; find "$My_Music" -iname "*.mp3" > Musiclist.txt ; y=$(sed 's@ @\\ @g' Musiclist.txt | wc -l); ((y=y+1)); typeset -i x; x=1; while ((x < y)) && fieldcut[x]=$(awk NR==$x Musiclist.txt | tr -d '[a-z,A-Z,0-9]',[' ','.','\55','\12','@','_','\50','\51','\47'] | wc -c) && path[x]=$(awk NR==$x Musiclist.txt | cut -d/ -f1-"${fieldcut[x]}") && file[x]=$(awk -F"/" -v line=$x 'NR==line{sub(/\..*/,"",$NF);print $NF}' Musiclist.txt) && ln -s "${path[x]}/${file[x]}".mp3 "${file[x]}".mp3; do ((x=x+1)); done ; x=1; while (( x < y )) && convert; do (( x=x+1)); done; rm -vf *.wav *.mp3 ; x=1; while (( x < 30)) && mv -v "${file[x]}".flac "${path[x]}"; do ((x=x+1)); done Code:
fieldcut[x]=$(awk NR==$x Musiclist.txt | tr -d '[a-z,A-Z,0-9]',[' ','.','\55','\12','@','_','\50','\51','\47'] | wc -c) && path[x]=$(awk NR==$x Musiclist.txt | cut -d/ -f1-"${fieldcut[x]}") Code:
y=$(sed 's@ @\\ @g' Musiclist.txt | wc -l); ((y=y+1)) The rest looks moderately trim to my unitiated eye. Now that it works -- to prune! Any suggestions, including instructions? :D (and i'd still like to know what's up with smeezekitty's code???) |
Shell bug?
I use that method all the time and it works fine. |
Quote:
I'll boot up Puppy and try the command here... |
All times are GMT -5. The time now is 01:28 PM. |