BOM or Byte-Order-Mark is needed by a UTF-8 CSV in order to be opened in Excel (at least for Windows). How to check if said BOM exist using bash? See below: 1~$ head -c3 samplefile.csv | hexdump -C 200000000 ef bb bf |...| 300000003
Read MoreBasic regex operator is =~ with basic syntax 1[[ "string" =~ pattern ]] NOTE pattern is not quoted, only the string. Very basic example when checking if a variable has either values 'running' or 'exited': 1status='running' ## change to 'exited' and '' to see it works 2if [[ …
Read More1#!/bin/bash 2sqlite3 test.db "create table n (id INTEGER PRIMARY KEY,f TEXT,l TEXT);" 3sqlite3 test.db "insert into n (f,l) values ('john','smith');" 4sqlite3 test.db "select * from n;" See stackoverflow post
Read MoreIn some cases, you may need to import the existing environments in bash. Use the following at the top of your script. 1if [ "${BASH_SOURCE[0]}" -ef "$0" ] 2then 3echo "Hey, you should source this script, not execute it!" 4exit 1 5fi See details in …
Read MoreThis error is seen as follows: 1sh:module:line1:syntaxerror:unexpectedendoffile2sh:errorimportingfunctiondefinitionfor`BASH_FUNC_module'A lot of discussions has been done about it in https://github.com/drush-ops/drush/issues/2065#issuecomment-227820550 but the fix is made from /etc/php.ini: 1disable_functions = …
Read More