我有一个包含文件列表的文本文件.我想把cat他们的内容放在一起.做这个的最好方式是什么?我正在做这样的事情,但它看起来过于复杂:
let count=0
while read -r LINE
do
[[ "$line" =~ ^#.*$ ]] && continue
if [ $count -ne 0 ] ; then
file="$LINE"
while read PLINE
do
echo $PLINE | cat - myfilejs > /tmp/out && mv /tmp/out myfile.js
done < $file
fi
let count++
done < tmp
Run Code Online (Sandbox Code Playgroud)
我正在跳过评论的行并遇到问题.必须有更好的方法来做到这一点,没有两个循环.谢谢!
密码保护视图的最佳方法是什么?我已经在生成密码,但我不想输入用户名和密码,只需输入密码.我目前将密码存储为File类中的属性,并使用此:
before_filter :restrict, :only => :show
authenticate_or_request_with_http_basic do |password|
password == @file.password
end
Run Code Online (Sandbox Code Playgroud)
但是,它仍然会提示用户输入用户名,但由于缺少用户名而无法正确登录.有没有办法使用这种方法,只有提示只询问密码?如果不是这样做的最佳方式是什么?
这可能是一个简单的答案,但谷歌搜索后我可能只是将术语缩小,所以我还没有找到任何关于我要问的内容.
当接受诸如/bin/*.txt之类的参数时,如何遍历每个文件?
我试过这个:
for file in $2; do
echo $file
done
Run Code Online (Sandbox Code Playgroud)
第二个参数($ 2)有一个输入,如/bin/*.txt,但echo只打印出6个文本文件中的1个.我是否错误地重复了这个?
我也尝试过使用ls,它也不能正确打印出来......
ls $2
Run Code Online (Sandbox Code Playgroud) 我已经在Heroku上运行了一个在本地运行良好的应用程序(在测试中使用sqlite3作为数据库的gem),当我推送到Heroku并尝试运行它时,我不断收到此错误:
ActiveRecord::StatementInvalid (PG::Error: ERROR: syntax error at or near "order"
LINE 1: ...lery_url_id = 'k19fv2mytjEb_3gCezLeRA') ORDER BY `order` ASC ^
: SELECT "pictures".* FROM "pictures" WHERE (gallery_url_id = 'k19fv2mytjEb_3gCezLeRA') ORDER BY `order` ASC):
app/controllers/galleries_controller.rb:38:in `show'
Run Code Online (Sandbox Code Playgroud)
特别是在这一行:
@pictures = Picture.find(:all, :conditions => [ 'gallery_url_id = ?', @gallery.url_id ], :order => "`order` ASC")
Run Code Online (Sandbox Code Playgroud)
注意:order是数据库字段,而不是SQL调用或引用.所以不要告诉我我正在做两个订单.那太傻了.除非以某种方式解析它.哪个也很傻.
我知道在本地测试中使用SQLite和在生产环境中使用PostgreSQL(pg)是一个问题.我的问题是我需要做些什么来解决这个问题?是否由于我在find中调用的标志只支持SQLite而不支持PostgreSQL?