Most of us know the heredoc method but what if you need a basic query done repeatedly and manually while working from bash? It is a pain to manually type mysql and login each time.
With this command below you can semi-automate those queries:
echo "use somedb; select * from auctions" | mysql -u root --password="yourpassword"
Just modify the above to suit your needs and you can add more queries by adding a sem........
This through me for a loop when I would do a cp -rf or mv -f nothing would get overwritten even if piping y or yes to the command.
Type alias and you'll see why:
alias cp='cp -i'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
The -i is a safeguard against messing things up but however does mess things up worse when you know what........
I've been struggling with this for awhile, wondering why all of my variables are null. Ijust realized the variables disappear after leaving this while loop.
Note that I'm piping to the while loop which makes a subshell Ibelieve which is the cause of the issue:
echo "$accounts"|while read thisline; do
(( ++counter ))
At all costs you ne........