use*_*837 4 scripting bash awk
我有一个包含用户名和密码的 CSV 文件。该文件如下所示:
user1,password1
user2,password2
user3,password3
Run Code Online (Sandbox Code Playgroud)
我需要遍历每一行来获取用户名和密码,使用这些变量,然后获取下一组用户名和密码,用新的变量替换变量的内容,等等。
我一直在寻找最好的方法来做到这一点,但我不是很熟悉脚本,我迷路了。我曾经awk单独抓住这两个,但我正在努力弄清楚如何awk在 while 循环中使用。我正在阅读这可能不是一个很好的方法。
假设您有一些不错的密码:
user1,",3 ""e`$^~´"
user2,""")& Eu`id`"
user3,ThisIsAlsoAGoodPasswordBecauseItIsLong
Run Code Online (Sandbox Code Playgroud)
然后你需要一些可以解析 CSV 的东西(“”里面的“是一个”)。
cat user+password.csv | parallel --csv do_stuff {1} {2}
Run Code Online (Sandbox Code Playgroud)
我认为这里不需要 awk:
#!/bin/bash
while IFS=, read -r user pass; do
# something with "$user" "$pass"
done < path/to/file.csv
Run Code Online (Sandbox Code Playgroud)