Timeline for Getting the last argument passed to a shell script
Current License: CC BY-SA 3.0
37 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 12, 2021 at 7:46 | answer | added | Truoc Pham | timeline score: 0 | |
Aug 30, 2020 at 15:18 | comment | added | Tom Hale |
Note: ${!#} doesn't work in zsh . For a solution which works in both {ba,z}sh, see here .
|
|
Oct 31, 2019 at 11:06 | answer | added | sripwoud | timeline score: -2 | |
Sep 29, 2019 at 14:56 | answer | added | Thain | timeline score: 2 | |
Oct 29, 2018 at 10:26 | answer | added | Tom Hale | timeline score: 10 | |
Aug 12, 2018 at 5:57 | answer | added | user8017719 | timeline score: 11 | |
Aug 5, 2018 at 10:33 | comment | added | Arch Stanton |
${!#} , unlike ${@: -1} , also works with parameter expansion. You can test it with bash -c 'echo ${!#%.*}' arg1.out arg2.out arg3.out .
|
|
Mar 13, 2018 at 19:56 | answer | added | Jurij | timeline score: 0 | |
Jul 22, 2017 at 21:19 | comment | added | oHo |
For only bash, the Kevin Little's answer proposes the simple ${!#} . Test it using bash -c 'echo ${!#}' arg1 arg2 arg3 . For bash, ksh and zsh, the Dennis Williamson's answer proposes ${@: -1} . Moreover ${*: -1} can also be used. Test it using zsh -c 'echo ${*: -1}' arg1 arg2 arg3 . But that does not work for dash, csh and tcsh.
|
|
Jun 2, 2016 at 20:48 | answer | added | Tahsin Turkoz | timeline score: 42 | |
Oct 6, 2015 at 11:43 | comment | added | Prateek Joshi | use can also use ${ !# } | |
Aug 17, 2015 at 15:21 | answer | added | esavier | timeline score: 1 | |
Oct 22, 2014 at 11:14 | answer | added | EndlosSchleife | timeline score: 4 | |
Oct 8, 2014 at 19:42 | answer | added | tekbot | timeline score: 0 | |
Jul 23, 2014 at 21:07 | answer | added | frank1rizzo | timeline score: 1 | |
Apr 28, 2014 at 17:18 | answer | added | Perfect64 | timeline score: 2 | |
Feb 10, 2014 at 15:27 | history | edited | Zombo | CC BY-SA 3.0 |
added 1 characters in body
|
Oct 31, 2013 at 2:00 | answer | added | Ranjithkumar T | timeline score: 0 | |
Feb 26, 2013 at 9:20 | answer | added | Paweł Nadolski | timeline score: 1 | |
Feb 1, 2013 at 15:47 | answer | added | Michał Šrajer | timeline score: 20 | |
Jan 22, 2013 at 15:52 | answer | added | David E. | timeline score: 1 | |
Jun 27, 2012 at 0:29 | answer | added | Zombo | timeline score: 108 | |
Jan 15, 2012 at 10:00 | answer | added | poiuz | timeline score: 26 | |
Mar 31, 2011 at 6:30 | answer | added | AgileZebra | timeline score: 31 | |
Mar 13, 2010 at 19:47 | answer | added | Kevin Little | timeline score: 81 | |
Dec 6, 2009 at 2:11 | comment | added | Inshallah | faqs.org/faqs/unix-faq/faq/part2/section-12.html | |
Dec 6, 2009 at 0:33 | vote | accept | Thomas | ||
Dec 6, 2009 at 0:26 | answer | added | Dennis Williamson | timeline score: 350 | |
Dec 6, 2009 at 0:21 | comment | added | Thomas | I was using bash, but the more portable solution the better. | |
Dec 6, 2009 at 0:16 | answer | added | Laurence Gonsalves | timeline score: 205 | |
Dec 6, 2009 at 0:15 | answer | added | Mikael S | timeline score: 2 | |
Dec 6, 2009 at 0:13 | answer | added | Mark Byers | timeline score: 36 | |
Dec 6, 2009 at 0:11 | answer | added | paxdiablo | timeline score: 2 | |
Dec 6, 2009 at 0:09 | answer | added | Laurence Gonsalves | timeline score: 5 | |
Dec 6, 2009 at 0:06 | answer | added | dusan | timeline score: 10 | |
Dec 6, 2009 at 0:02 | answer | added | Craig Trader | timeline score: 0 | |
Dec 5, 2009 at 23:58 | history | asked | Thomas | CC BY-SA 2.5 |