以下是我所拥有的脚本的片段,它试图对子目录中的所有php文件进行tar.它尝试使用'--include'参数,但似乎不起作用(输出来自bash中的'set -x')
+ find . -name '*.php'
./autoload.php
./ext/thrift_protocol/run-tests.php
./protocol/TBinaryProtocol.php
...
./transport/TTransportFactory.php
+ tar -cvjf my.tar.bz2 '--include=*.php' .
+ set +x
Run Code Online (Sandbox Code Playgroud)
在find发现了几个PHP文件,但焦油似乎并没有看到他们.如果我拿出--include所有文件都涂焦油.
我知道我可以使用find来提供list(find . -name '*.php' -print0 | tar -cvjf "my.tar.bz2" --null -T -),但是--includeparam有什么问题?
编辑:
我在下面的评论 sed 's@^@ @' <(f1)是不正确的虽然$BASH_SUBSHELL表明我们与启动处于同一级别,但变量在主脚本中丢失.根据戈登的回答,我测试了f1 > >(sed 's@^@ @'),这似乎工作正常.不过,对于第一种形式,BASH_SUBSHELL不应该是1而不是0吗?
考虑这个小测试
#!/bin/bash
declare -i i=0
function f1()
{
let i++
echo "In f1, SUBSHELL: $BASH_SUBSHELL, i=$i" >&2
}
f1
f1 | sed 's@^@ @'
echo "at end, i=$i"
Run Code Online (Sandbox Code Playgroud)
具有以下输出:
In f1, SUBSHELL: 0, i=1
In f1, SUBSHELL: 1, i=2
at end, i=1
Run Code Online (Sandbox Code Playgroud)
(目的sed只是为了得到一些东西,不要指望它做任何事情,因为f1输出到stderr)
函数f1记录当前的BASH_SUBSHELL和i的当前值
我知道为什么在我们得到的脚本结束时i=1,因为第二次调用是在子shell中,并且子shell 1中i的值丢失了.
我不知道为什么管道的左侧没有在当前的shell中执行
虽然我认为我可以避免这种情况,但sed 's@^@ @' <(f1)
我想知道为什么左侧与主脚本不在同一级别
有没有办法将两个操作组合成一个键绑定(不要认为可以使用函数).
这就是我想做的事情:
我想要一个键绑定(比如Ctrl-X) -
我知道我可以(在~/.inputrc)指定
C-X: "ls")插入文本C-SPACE: menu-complete)但我不知道如何把它们放在一起
我有C++程序,现在生成两个文件:
所以,对于情节我需要有两个相互关联的文件.
是否有可能将它全部打包到一个文件中?我的意思是:把数据点坐标放在gnuplot脚本里面?
我正在使用gnuplot 4.4.
使用Boost 1_33_1,我得到一个错误,暗示我的迭代器是一个const迭代器(因为它不会让我从find()中得到结果).
$ g++ bmi_iter_tst.cpp
bmi_iter_tst.cpp: In function ‘void tst(employee_set&)’:
bmi_iter_tst.cpp:32: error: invalid initialization of reference of type ‘employee&’ from expression of type ‘const employee’
Run Code Online (Sandbox Code Playgroud)
我知道我不应该修改任何键值,但我没有,但我仍然需要非const访问sto修改容器元素中的其他数据.
我知道我已经在其他地方成功完成了这项工作,我只是看不出是什么会使这个const.
下面的代码源自原始boost::multi_index示例
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/ordered_index.hpp>
using boost::multi_index_container;
using namespace boost::multi_index;
struct employee
{
int id;
int tst;
employee(int id_):id(id_), tst(0){}
};
struct id{};
typedef multi_index_container<
employee,
indexed_by<
ordered_unique<
tag<id>, BOOST_MULTI_INDEX_MEMBER(employee,int,id)> >
> employee_set;
void tst(employee_set& s)
{
employee_set::index_iterator<id>::type it = s.get<id>().find(11);
employee& eref = *it;
eref.tst++;
}
Run Code Online (Sandbox Code Playgroud) 2>&1>"和使用过程中的重定向" |"我一直想知道的是关于上述两者的结合
如果要将prog1的 STDERR和STDOUT重定向到prog2,则将2>&1前一个放在|prog2管道上.另一方面,如果你将prog1的STDERR和STDOUT重定向到一个文件(file.txt),那么就是2>&1在> file.txt.
所以我知道怎么做,我只是想知道为什么这样做.对我而言似乎不一致,但我可能会以错误的方式看待它
谢谢
我希望找到一种方法来从uBoots命令提示符增加RAM中的值.
简而言之,我的设备上的地址0xc4000000是一个临时变量,我需要递增
想法?
__PRE__
给出以下测试代码
#include <iostream>
#include <tr1/functional>
using namespace std;
struct cl {
cl(){ cout << " cl()\n"; }
cl(const cl& from){ cout << " cl()[copy]\n"; }
~cl(){ cout << " ~cl()\n";}
};
void f1(const cl& data){}
void f2(const cl* pData){}
int main(int c, char** a)
{
cout << "enter:\n";
cl data;
cout << "ref:\n";
tr1::bind(&f1, data);
cout << "ptr:\n";
tr1::bind(&f2, &data);
cout << "exit:\n";
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我得到以下输出:
$ g++ tr1BindDtorTest.cpp && ./a.out
enter:
cl()
ref:
cl()[copy]
cl()[copy]
cl()[copy]
~cl()
~cl() …Run Code Online (Sandbox Code Playgroud) 编辑:我见过这种方法有效的情况和无效的情况,我不确定我何时/为何这样做。
假设我有一个足够复杂的条目,我在其中指定了多个参数thathost:
Host thathost
ControlMaster auto
ServerAliveInterval 8
ConnectTimeout 8
Hostname 192.168.5.1
User mememe
ProxyJump thejumpbox
Run Code Online (Sandbox Code Playgroud)
我想在创建其他条目时重新使用此定义,通过添加或覆盖某些配置来提供不同的功能。特别指定备用端口(不,我不想在命令行上使用它)。
理想情况下我能够做类似的事情
Host theirhost
Hostname thathost
User themthem
Run Code Online (Sandbox Code Playgroud)
或者
Host my-remote-serialport
Hostname thathost
RequestTTY yes
RemoteCommand some-script-that-launches-kermit-on-a-specific-dev-tty
Run Code Online (Sandbox Code Playgroud)
或者
Host my-remote-serialport
Hostname thathost
Port 3004
Run Code Online (Sandbox Code Playgroud)
我严格要求根据另一台现有主机来指定一台主机,我不想修改我的Host条目以匹配某些模式“技巧”。
显然,我可以利用ProxyCommand ssh -q nc thathost...or ProxyJump thathost+Hostname localhost后跟所有其他覆盖(对于端口覆盖来说,会将其传递给nc),但这既丑陋又浪费(额外的会话) - 请不要回答这个问题。
对我来说,这是 的缺失功能ssh-config,但也许我看起来不够仔细。