command-line

Iterate over arguments in a bash script and make use of their numbers

白昼怎懂夜的黑 提交于 2020-08-27 11:38:03
问题 If I want to iterate over all arguments it is as easy as for i in "$@"; do ... . However, let's say I want to start with the second argument and also make use of the arguments' positions for some basic calculation. As an example I want to shorten these commands into one loop: grep -v 'foobar' "$2" | grep -f $file > output1.txt grep -v 'foobar' "$3" | grep -f $file > output2.txt grep -v 'foobar' "$4" | grep -f $file > output3.txt grep -v 'foobar' "$5" | grep -f $file > output4.txt I tried many

Iterate over arguments in a bash script and make use of their numbers

狂风中的少年 提交于 2020-08-27 11:37:48
问题 If I want to iterate over all arguments it is as easy as for i in "$@"; do ... . However, let's say I want to start with the second argument and also make use of the arguments' positions for some basic calculation. As an example I want to shorten these commands into one loop: grep -v 'foobar' "$2" | grep -f $file > output1.txt grep -v 'foobar' "$3" | grep -f $file > output2.txt grep -v 'foobar' "$4" | grep -f $file > output3.txt grep -v 'foobar' "$5" | grep -f $file > output4.txt I tried many

git log --before=“4 months” show me branches that have commits from 3 weeks ago. what am I doing wrong?

浪子不回头ぞ 提交于 2020-08-25 17:41:14
问题 so I have this snippet that I want to use to filter out branches that doesn't have a certain prefix and that hasn't received any commits in over 3 months so that I can remove them from our remote later on. for k in $(git branch -r | awk -Forigin !'/\/Prefix1\/|\/prefix2\//'); do if [ "$(git log -1 --before="3 month" $k)" ]; then echo "$(git log -1 --pretty=format:"%ci, %cr, " $k) $k"; fi; done The problem is currently that when I run this I see branches that have received commits 3 weeks ago,

How to execute in PHP interactive mode

岁酱吖の 提交于 2020-08-22 01:55:28
问题 I am new to PHP, and I just wanted to run PHP in a command prompt (interactive mode). So I typed this code: `php -v` `<?php` `echo 7;` `?>` But I do not know how to execute it, because when I press Enter cmd expects me to continue writing the code. I searched on php.net and some other forums, but I didn't find anything. So is there a function key or something to display the result? 回答1: Ctrl + d will trigger an end-of-file condition and cause the script to be executed. See also How does the