很抱歉之前有人问过这个问题,但我不能让这个开始工作。我只想在一个行的开头加上一个单引号,在文件的行尾加上一个逗号。
我想得到这样的东西:
从DBNAME中选择值在(“ONE”)中的 “二”, “三重”,
但我得到的是:
从DBNAME中选择值为( 'ONE )的 ', “两次 ', 三重 ',
这是我的密码:
echo "select something from DBNAME where VALUE in (" > /path/to/file.sql
sed 's/^/\x27/g; s/$/\x27,/g' /path/to/one/two/three/file.txt
cat /path/to/one/two/three/file.txt >> /path/to/file.sql如您可能已经猜到的那样,/path/to/one/2/3/file.txt的内容:
一 二 三
发布于 2018-12-03 01:05:01
$ cat file
ONE
TWO
THREE
$ awk '
BEGIN { printf "select something from DBNAME where VALUE in (" }
{ print "\047" $0 "\047," }
' file
select something from DBNAME where VALUE in ('ONE',
'TWO',
'THREE',https://stackoverflow.com/questions/53586088
复制相似问题