{"id":1265,"date":"2019-04-24T17:58:27","date_gmt":"2019-04-24T12:58:27","guid":{"rendered":"http:\/\/alexeyka.zantsev.com\/?p=1265"},"modified":"2020-09-28T11:12:13","modified_gmt":"2020-09-28T06:12:13","slug":"bash-convert-list-of-words-to-one-line","status":"publish","type":"post","link":"https:\/\/alexeyka.zantsev.com\/?p=1265","title":{"rendered":"Bash: convert word list to one line"},"content":{"rendered":"\n<pre class=\"wp-block-preformatted\">bastion@host:~$ cat pids.txt <br> 1111<br> 2222<br> 3333<br> 4444<br>bastion@host:~$ echo $(cat pids.txt)<br> 1111 2222 3333 4444<br><br><\/pre>\n\n\n\n<p>for i in `<code><code>echo $(cat killpids.txt)`<\/code><\/code> ; do kill -9 $i ; done<\/p>\n\n\n\n<p>UPD: a note with alternative commands from <a rel=\"noreferrer noopener\" href=\"https:\/\/twitter.com\/liviuchircu\" target=\"_blank\">Liviu Chircu<\/a>, OpenSIPS core developer:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1.&nbsp; instead of `echo $(cat pids.txt)`, a better alternative would be:\n`cat pids.txt | xargs`\n\n2.&nbsp; instead of \"for i in `echo $(cat pids.txt)`;&nbsp; do kill -9 $i; done\",\na better option would be: `cat pids.txt | xargs kill -9`<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>bastion@host:~$ cat pids.txt 1111 2222 3333 4444bastion@host:~$ echo $(cat pids.txt) 1111 2222 3333 4444 for i in `echo $(cat killpids.txt)` ; do kill -9 $i ; done UPD: a note with alternative commands from Liviu Chircu, OpenSIPS core developer: 1.&nbsp; instead of `echo $(cat pids.txt)`, a better alternative would be: `cat pids.txt | xargs` 2.&nbsp; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[102],"class_list":["post-1265","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-bash"],"_links":{"self":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts\/1265","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1265"}],"version-history":[{"count":6,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts\/1265\/revisions"}],"predecessor-version":[{"id":1468,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts\/1265\/revisions\/1468"}],"wp:attachment":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1265"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1265"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1265"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}