I have a file which is encoded by base64:
5byg5bCP5piO
c2FyYWg=
5p2O56OK
I want to decode it line by line:
:%!base64 -d
But I get everything in one line:
张小明sarah李磊
What I want is:
张小明
sarah
李磊
How can I do it?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.
Sign up to join this communityAnother solution is the following, which works nicely for me.
%g/^/.!base64 -d
%
is in case of :g
redundant. Also the .
regexp makes sense - no use to try to decode empty lines.
:%normal !!base64 -d^M
:{range}norm[al][!] {commands} *:normal-range*
Execute Normal mode commands {commands} for each line
in the {range}. Before executing the {commands}, the
cursor is positioned in the first column of the range,
for each line. Otherwise it's the same as the
":normal" command without a range.
{not in Vi}
Not available when |+ex_extra| feature was disabled at
compile time.
Yet another way:
sed 's/$/Cg==/' | base64 -d