Bash or GoogleCL: new line in a string parameter

2019-02-27 15:44发布

HI, I am using GoogleCL version 0.9.11 to upload videos to Youtube. My OS is CentOS 5.5 and Python 2.5.

One of the string parameters contain new line "\n", and it cant display properly.

google youtube post ~/videos/cat-falls-down-stairs.avi Comedy --tags "currency of the internet" --summary "Poor whiskers takes a tumble.\nShe's fine, though, don't worry."

The summary page display as:

Poor whiskers takes a tumble.\nShe's fine, though, don't worry.

But I want:

Poor whiskers takes a tumble.
She's fine, though, don't worry.

The "\n" wont work. Who has a solution?

Thanks a lot!

3条回答
叼着烟拽天下
2楼-- · 2019-02-27 16:23

You can use Bash's $'' construct to expand escape sequences before they are passed to googlecl.

google youtube post ~/videos/cat-falls-down-stairs.avi Comedy \
    --tags 'currency of the internet' \
    --summary $'Poor whiskers takes a tumble.\nShe'\''s fine, though, don'\''t worry.'
查看更多
The star\"
3楼-- · 2019-02-27 16:28

Just put an acutal newline in side the string. Bash knows how to handle multi-line strings if you just press enter in the middle of them.

google youtube post ~/videos/cat-falls-down-stairs.avi Comedy --tags "currency of the internet" --summary "Poor whiskers takes a tumble.
She's fine, though, don't worry."
查看更多
Juvenile、少年°
4楼-- · 2019-02-27 16:29

googlecl is a python application. Escape the \n with a \ and have your string as "Poor whiskers takes a tumble.\\nShe's fine..." . This should perhaps help.

查看更多
登录 后发表回答