User Tools

Site Tools


code:nice_scripts

Differences

This shows you the differences between two versions of the page.


code:nice_scripts [2021/03/08 17:57] (current) – created - external edit 127.0.0.1
Line 1: Line 1:
 +====== Nice Scripts ======
 +===== Welcome to Shell Scripting! =====
 +==== Parsing Configs ====
 +The file.csv file content is :
 +<file>
 +user0001;password0001;user0002;password0002
 +user0011;password0011;user0012;password0012 ...
 +</file>
 +
 +And the shell program is just :
 +  { while IFS=';' read u1 p1 u2 p2; do imapsync --user1 $u1 --password1
 +  $p1 --user2 $u2 --password2 $p2 ... done ; } < file.csv
 +
 +==== Bash Readarray ====
 +
 +Better than the above ''while read'' loop is the use of Bash's builtin
 +''readarray'' as it allows to avoid spawning a sub-shell and therefore variable
 +assignments from inside the loop work.