将文件的每一行都传递给命令

时间:2013-06-20 12:47:37

标签: shell command-line base64 xargs

我有一个文本文件,每行是一个单词编码base64 separely。现在我想解码它。我正在尝试使用base64命令行,但是我只能在一行中获取所有单词,我想要每行一个。

例如,我的文件是:

Y2F0Cg==
ZG9nCg==
aG91c2UK

我想要结果:

dog
cat
house

但我得到了:

dogcathouse

我认为xargs可以提供帮助,但我没有明白这一点。

4 个答案:

答案 0 :(得分:12)

base64 --decode与循环一起使用:

$ while IFS= read -r line; do echo "$line" | base64 --decode; done < file
cat
dog
house

答案 1 :(得分:4)

这适用于我base64 8.13:

base64 --decode test.txt

无需拆分文件。你使用的是哪个版本?

答案 2 :(得分:0)

你可以使用Python(不需要阅读每一行):

python -m base64 -d foo.txt

答案 3 :(得分:0)

您可以为此使用bash此处文档import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class PassAccount { static String dropdownValue; } class ToContainer extends StatefulWidget { final PassAccount dropdownValue; ToContainer({Key key, this.dropdownValue}) : super(key: key); @override _ToContainerState createState() => _ToContainerState(); } class _ToContainerState extends State<ToContainer> { //var AccountSelected = PassAccount.dropdownValue; @override Widget build(BuildContext context) { var AccountSelected = PassAccount.dropdownValue; return Container( color: Colors.white, child: Column( children: <Widget>[ Container( padding: EdgeInsets.only( top: 5.0, left: 10.0, right: 10.0, bottom: 10.0), child: SafeArea( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Row( children: <Widget>[ Expanded( child: CupertinoButton( child: Text( 'Next', //style: style.clickButton, ), onPressed: () { var route = new MaterialPageRoute( builder: (BuildContext context) => new DirectedScreen( value: PassData( account: AccountSelected, )), ); Navigator.of(context).push(route); }, color: Colors.blue[600], borderRadius: BorderRadius.circular(200.0), disabledColor: Colors.grey, ), ), ], ), ], ), ), ), ], ), ); } } class PassData { final String account; const PassData({this.account}); } class DirectedScreen extends StatefulWidget { final PassData value; DirectedScreen({Key key, this.value}) : super(key: key); @override _DirectedScreenState createState() => _DirectedScreenState(); } class _DirectedScreenState extends State<DirectedScreen> { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, appBar: AppBar( title: Text('Transfer Summary'), ), body: Container( child: new Center( child: Column( children: <Widget>[ Padding( child: new Text( 'PASSED VALUES', style: new TextStyle( fontWeight: FontWeight.bold, fontSize: 20.0), textAlign: TextAlign.center, ), padding: EdgeInsets.only(bottom: 20.0), ), Padding( child: new Text( 'Bank : ${widget.value.account}', style: new TextStyle(fontWeight: FontWeight.bold), textAlign: TextAlign.left, ), padding: EdgeInsets.all(10.0), ), ], ), ), ), ); } } void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, visualDensity: VisualDensity.adaptivePlatformDensity, ), home: MyHomePage(title: 'Flutter Demo Home Page'), ); } } class MyHomePage extends StatefulWidget { MyHomePage({Key key, this.title}) : super(key: key); final String title; @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { int _counter = 0; @override void initState() { PassAccount.dropdownValue = "456"; super.initState(); } void _incrementCounter() { PassAccount.dropdownValue = "789"; setState(() { _counter++; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(widget.title), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ ToContainer(), Text( 'You have pushed the button this many times:', ), Text( '$_counter', style: Theme.of(context).textTheme.headline4, ), ], ), ), floatingActionButton: FloatingActionButton( onPressed: _incrementCounter, tooltip: 'Increment', child: Icon(Icons.add), ), ); } }

<<<