{"id":701,"date":"2022-02-17T22:52:33","date_gmt":"2022-02-18T03:52:33","guid":{"rendered":"https:\/\/molecularsciences.org\/content\/?p=701"},"modified":"2024-02-09T14:45:03","modified_gmt":"2024-02-09T19:45:03","slug":"reading-files-in-a-directory-using-bash","status":"publish","type":"post","link":"https:\/\/molecularsciences.org\/content\/reading-files-in-a-directory-using-bash\/","title":{"rendered":"Reading files in a directory using bash"},"content":{"rendered":"\n<p>The following code reads files in a directory called SQL. Then if runs an SQL command with the file name as input. Finally, it deletes the file from the directory.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n\nfor file in sql\/*\ndo\n  echo \"Processing $file\\n\"\n  mysql -u root -pdonut node2 &lt; $file\n  rm -f $file\ndone<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The following code reads files in a directory called SQL. Then if runs an SQL command with the file name as input. Finally, it deletes the file from the directory.<\/p>\n","protected":false},"author":1,"featured_media":1241,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101,34],"tags":[94,209,35],"class_list":["post-701","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bash","category-linux","tag-bash","tag-file-management","tag-linux"],"_links":{"self":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/701","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/comments?post=701"}],"version-history":[{"count":1,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/701\/revisions"}],"predecessor-version":[{"id":702,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/701\/revisions\/702"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/media\/1241"}],"wp:attachment":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/media?parent=701"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/categories?post=701"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/tags?post=701"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}