bash

C++: Read from stdin as data is written into pipe

Deadly 提交于 2021-02-11 11:22:00
问题 I have two C++ programs: one that prints a message to stdout, and the other that listens to stdin and prints all content from the stream. They are named out and in respectively. out.cpp: #include <iostream> using namespace std; int main() { cout<<"HELLO"; usleep(1000000); cout<<"HELLO"; } in.cpp: #include <iostream> using namespace std; int main() { string input; while(cin>>input) { cout<<input; } } As it currently stands, piping the data from out to in waits for two seconds, then prints

C++: Read from stdin as data is written into pipe

こ雲淡風輕ζ 提交于 2021-02-11 11:19:50
问题 I have two C++ programs: one that prints a message to stdout, and the other that listens to stdin and prints all content from the stream. They are named out and in respectively. out.cpp: #include <iostream> using namespace std; int main() { cout<<"HELLO"; usleep(1000000); cout<<"HELLO"; } in.cpp: #include <iostream> using namespace std; int main() { string input; while(cin>>input) { cout<<input; } } As it currently stands, piping the data from out to in waits for two seconds, then prints

bash script exit codes for dialog menu

半世苍凉 提交于 2021-02-11 10:46:42
问题 I have a code menu "Pasirinkite:" 0 0 0 \ iraso_ivedimas "iraso irasymas i kontaktu knygele" \ iraso_pdialog --title "Meniu" \ --menu "Pasirinkite:" 0 0 0 \ iraso_ivedimas "iraso irasymas i kontaktu knygele" \ iraso_paieska "iraso paieska pagal varda" \ iraso_perziura "viso iraso perziura" \ iraso_salinimas "iraso salinimas pagal eiles numeri" 2>f.txt kint=$? case $kint in 0)p=`cat f.txt` case $p in iraso_ivedimas)dialog --inputbox "Iveskite varda" 0 0 2>kvardas.txt vardp=`cat kvardas.txt`

replace path value of a variable in file with bash

一笑奈何 提交于 2021-02-11 07:42:43
问题 I have a namelist containing inputs for simulations. I have to change the path of some variables using bash. The text file has the following value that I would like to change: opt_path = '/home/gle/test_workflow', I would like to replace the value of opt_path with cat and sed, and I tried the following but it doesn't work: new_path=/my/new/path cat namelist.wps | sed "s/^opt_path.*/opt_path = '${new_path}'/g" it returns the following error: sed: -e expression #1, char 29: unknown option to `s

How to read a file and get certain lines in Linux

帅比萌擦擦* 提交于 2021-02-11 07:16:19
问题 I have a file and it has content like this: abc.com. IN A 10.10.40.94 ;10.120.40.61 ;10.60.3.135 def.com. IN CNAME some-domain.com. xyz.com. IN A 10.123.40.32 ;10.145.40.133 ;1.240.3.215 one.com. IN CNAME some-other-domain.com. What I want to do is, get all the lines with IN A and print them to another file so the final file would look like below: I tried awk as follows: cat dev-mytaxi.com.zone | awk '{print $3}' but how can I write to a file and the final outcome as mentioned below? final

How to read a file and get certain lines in Linux

送分小仙女□ 提交于 2021-02-11 07:15:56
问题 I have a file and it has content like this: abc.com. IN A 10.10.40.94 ;10.120.40.61 ;10.60.3.135 def.com. IN CNAME some-domain.com. xyz.com. IN A 10.123.40.32 ;10.145.40.133 ;1.240.3.215 one.com. IN CNAME some-other-domain.com. What I want to do is, get all the lines with IN A and print them to another file so the final file would look like below: I tried awk as follows: cat dev-mytaxi.com.zone | awk '{print $3}' but how can I write to a file and the final outcome as mentioned below? final

How to read a file and get certain lines in Linux

妖精的绣舞 提交于 2021-02-11 07:15:04
问题 I have a file and it has content like this: abc.com. IN A 10.10.40.94 ;10.120.40.61 ;10.60.3.135 def.com. IN CNAME some-domain.com. xyz.com. IN A 10.123.40.32 ;10.145.40.133 ;1.240.3.215 one.com. IN CNAME some-other-domain.com. What I want to do is, get all the lines with IN A and print them to another file so the final file would look like below: I tried awk as follows: cat dev-mytaxi.com.zone | awk '{print $3}' but how can I write to a file and the final outcome as mentioned below? final

How to read a file and get certain lines in Linux

佐手、 提交于 2021-02-11 07:14:12
问题 I have a file and it has content like this: abc.com. IN A 10.10.40.94 ;10.120.40.61 ;10.60.3.135 def.com. IN CNAME some-domain.com. xyz.com. IN A 10.123.40.32 ;10.145.40.133 ;1.240.3.215 one.com. IN CNAME some-other-domain.com. What I want to do is, get all the lines with IN A and print them to another file so the final file would look like below: I tried awk as follows: cat dev-mytaxi.com.zone | awk '{print $3}' but how can I write to a file and the final outcome as mentioned below? final

ElasticSearch-head 操作时,报 406错误码

十年热恋 提交于 2021-02-11 07:06:53
查询时报错{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406} 解决方法: 1、进入head安装目录;docker exec -it 名称 bash 2、打开文件夹_site,cd _site/ 3、编辑vendor.js 共有两处   ①. 6886行 contentType: "application/x-www-form-urlencoded     改成     contentType: "application/json;charset=UTF-8"   ②. 7574行 var inspectData = s.contentType === "application/x-www-form-urlencoded" &&     改成    var inspectData = s.contentType === "application/json;charset=UTF-8" && 4、退出容器exit 然后重启 5、重新查询,可以查出数据 来源: oschina 链接: https://my.oschina.net/u/4258573/blog/3327635

Bash - how to make arithmetic expansion in range braces?

一曲冷凌霜 提交于 2021-02-11 07:00:09
问题 I want to do this: for i in {1.."$((2**3))"}; do echo "$i"; done But that would output {1..8} , which I want to execute, not output. How to? 回答1: You can't do in like that in bash, brace expansion happens before variable does. A c-style for loop can be an alternative. for ((i = 1; i <= 2**3; i++)); do printf '%d ' "$i"; done ... Or if you really want to do the brace expansion use eval which is not advised to use but it is the only way... eval echo {1..$((2**3))} See the local bash manual for