我有以下命令:
find . -type d -mtime 0 -exec mv {} /path/to/target-dir \;
Run Code Online (Sandbox Code Playgroud)
这会将创建的目录移动到另一个目录.如何使用xargs而不是exec做同样的事情.
以下是Bash进程替换的示例:
zjhui@ubuntu:~/Desktop$ echo >(ls)
/dev/fd/63
zjhui@ubuntu:~/Desktop$ abs-guide.pdf
Run Code Online (Sandbox Code Playgroud)
然后我得到一个光标等待命令.
/dev/fd/63不存在.我想会发生的是:
/dev/fdlsin>(ls)这是正确的吗?为什么有光标等待输入?
每一个人.我想写一个bash脚本来使用终端的google翻译并将英文翻译成中文.我的计划是首先使用wget来翻译英语,然后使用sed来获得结果.所以我用
wget -qO- --header="Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" --header="Accept-Charset:GBK,utf-8;q=0.7,*;q=0.3" --header="Accept-Encoding:gzip,deflate,sdch" --header="Accept-Language:en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4" -U "Mozilla/5.0 (X11; Linux i686) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.27 Safari/536.11" http://translate.google.cn/#en/zh-CN/hello | gunzip > out.html.
我也试过了wget -U "Mozilla/5.0" http://translate.google.cn/#en/zh-CN/hello.
他们的结果似乎都不是我想要的,因为我??从结果中找不到中文.
我有什么问题?
Ruby:2.0.0p0,Rails:3.2.13
my rake routes:
questions GET /questions(.:format) questions#index
POST /questions(.:format) questions#create
new_question GET /questions/new(.:format) questions#new
edit_question GET /questions/:id/edit(.:format) questions#edit
question GET /questions/:id(.:format) questions#show
PUT /questions/:id(.:format) questions#update
DELETE /questions/:id(.:format) questions#destroy
Run Code Online (Sandbox Code Playgroud)
QuestionsCotroller:class QuestionsController <ApplicationController
class QuestionsController < ApplicationController
def index
@questions = Question.all
end
def show
@question = Question.find(params[:id])
end
def new
@question = Question.new
end
def create
@question = Question.new(params[:question])
# @question.save!
# flash[:notic] = 'Page saved'
# redirect_to :action => 'index'
# rescue ActiveRecord::RecordInvalid
# render :action => …Run Code Online (Sandbox Code Playgroud) 我有一个简单的问题与bash的大括号扩展:
#!/bin/bash
PICS="{x1,x2,x3}.jpg {y1,y2}.png"
for i in $PICS
do
echo $i
done
Run Code Online (Sandbox Code Playgroud)
但结果是:
{x1,x2,x3} .jpg
{y1,y2} .png
但我希望结果是:x1.jpg x2.jpg x3.jpg y1.png y2.png
我该怎么办?