Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pipe each line of a file to a command

I have a text file which each line is a one word coded base64 separely. Now I want to decode it. I'm trying to use base64 command line, but I'm getting all the words in only one line, I want one per line.

For example, my file is:

Y2F0Cg==
ZG9nCg==
aG91c2UK

I want as result:

dog
cat
house

But I'm getting:

dogcathouse

I think xargs could help, but I'm not getting the point.

like image 543
tpcordeiro Avatar asked Jun 20 '13 12:06

tpcordeiro


2 Answers

You can use Python for that (no need for reading each line):

python -m base64 -d foo.txt
like image 176
kenorb Avatar answered Sep 22 '22 12:09

kenorb


This works for me in base64 8.13:

base64 --decode test.txt

No need to split the file. Which version are you using?

like image 43
l0b0 Avatar answered Sep 18 '22 12:09

l0b0