ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
What shell is executing this? What does "type echo" show? It looks like your echo command is treating "," as an operator.
Just a suggestion unrelated to yuor problem: You don't need to test for a nonexistent or zero-length "$db" file. The ">>" redirection will create the file if it does not currently exist.
Thanks for the simple code shruggy , but i have the same problem as before , that did not solve the variables that i need to write in data.csv .
We returned to point 0 again .
By default in every thread i make here someone always simplify the code ))
$ drd=/media/Disk5/Flac/xxx;cueprint -t"%p - %t , $drd\n" wp.cue
Faithless - Reverence , /media/Disk5/Flac/xxx
Faithless - She's My Baby , /media/Disk5/Flac/xxx
Faithless - Take the Long Way Home , /media/Disk5/Flac/xxx
Faithless - Insomnia , /media/Disk5/Flac/xxx
Faithless - Bring the Family Back , /media/Disk5/Flac/xxx
Faithless - Salva Mea , /media/Disk5/Flac/xxx
Faithless - Dirty Old Man , /media/Disk5/Flac/xxx
Faithless - God Is a DJ , /media/Disk5/Flac/xxx
Of course, this would work only as long as you don't have any % in $drd. Just extracting performer and title with cueprint would be safer.
$ cueprint -t'%p - %t\n' hak.cue
The Specials - Gangsters
The Specials - Rudi, A Message To You
The Specials - Nite Klub
The Specials - Too Much Too Young
The Specials - Guns Of Navarone
The Specials - Rat Race
The Specials - Stereotype
The Specials - International Jet Set
The Specials - Do Nothing
The Specials - Ghost Town
The Specials - Why?
The Specials - Friday Night, Saturday Morning
The Specials - War Crimes
The Specials - Racist Friend
The Specials - Nelson Mandela
The Specials - (What I Like Most About You Is Your) Girlfriend
Or you may double each % in $drd for cueprint
Code:
$ drd="/media/Disk5/Flac/From 0% to 100%"; echo ${drd//%/%%}
/media/Disk5/Flac/From 0%% to 100%%
$ cueprint -t"%p - %t , ${drd//%/%%}\n" wp.cue
Faithless - Reverence , /media/Disk5/Flac/From 0% to 100%
Faithless - She's My Baby , /media/Disk5/Flac/From 0% to 100%
Faithless - Take the Long Way Home , /media/Disk5/Flac/From 0% to 100%
Faithless - Insomnia , /media/Disk5/Flac/From 0% to 100%
Faithless - Bring the Family Back , /media/Disk5/Flac/From 0% to 100%
Faithless - Salva Mea , /media/Disk5/Flac/From 0% to 100%
Faithless - Dirty Old Man , /media/Disk5/Flac/From 0% to 100%
Faithless - God Is a DJ , /media/Disk5/Flac/From 0% to 100%
A thought. Could a performer name start with a dash? Then better use printf rather than echo.
But I don't think echo is the culprit. Rather the way you generate art and song looks fragile and problematic:
Code:
grep "PERFORMER" "$scue" | sed 's/PERFORMER//' | sed 's/"//g' | sed 's/^ *//g' | sed '/^[[:space:]]*$/d' | uniq > "$art"
grep "TITLE" "$scue" | sed 's/TITLE//' | sed 's/"//g' | sed 's/^ *//g' | sed '/^[[:space:]]*$/d' | sed -e '1d' > "$song"
Even if you simplify it like this
Code:
sed '/PERFORMER/!d;s///;s/"//g;s/^ *//;/^$/d' "$scue"|uniq >"$art"
sed '/TITLE/!d;s///;s/"//g;s/^ *//;/^$/d' "$scue" >"$song"
But I don't know the cue sheet file format enough to judge. Again, rather than doing ad-hoc parsing with sed, I'd use a specialized tool (cueprint).
Alan Barry
- Good Vibrations (Radio Version)
/media/Disk5/Flac/Albums & Remixed/Alan Barry - Greatest Hits & Remixes (2019)/CD1
Alan Barry
- Come On (Radio Version)
/media/Disk5/Flac/Albums & Remixed/Alan Barry - Greatest Hits & Remixes (2019)/CD1
I have no idea why cat dont show everything , i only notice it now when i used nano .
Also they are not on same line , they are in separated lines each variable !!!!
For last and more strange i get in nano "read 271 lines (Converted from Mac format)" !!!
i am not in mac , i am in linux and data.csv was created in linux .
Quote:
root@Cloud:/usr/local/share/dbserver# file data.csv
data.csv: CSV text
image11 attached shows file opened on leafpad editor
Any idea ?
That means there are embedded CR characters (\r, ^M, ASCII 13). cat -A will show them.
An explanation that I have. Your .cue files are in DOS format (CRLF). Again, cat -A will show it. Command substitution $() and mapfile -t will remove trailing LF (\n, ^J, ASCII 10), but CR will be left intact. When you cat it, the lines get overlapped, i.e. performer gets overwritten by title which in turn gets overwritten by $drd (remember how carriage return on a typewriter works).
sed 's/\s*$//' to the rescue.
Again, I'm pretty sure that cueprint can cope with this.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.