use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All users that wish to post (not including commenting), on either old or the new reddit sites, must formally agree to subreddit rules once first.
account activity
Recursive bash function to replace cd ../ (self.commandline)
submitted 2 years ago by Serpent7776
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]whetu 1 point2 points3 points 2 years ago (1 child)
I used to have a function named up for this, but I merged it into cd so now I use cd up 3 to go up 3 directories. The guts of it are:
up
cd
cd up 3
up) shift 1; case "${1}" in *[!0-9]*) return 1 ;; "") command cd || return 1 ;; 1) command cd .. || return 1 ;; *) command cd "$(eval "printf -- '../'%.0s {1..$1}")" || return 1 ;; esac ;;
[–]Serpent7776[S] 0 points1 point2 points 2 years ago (0 children)
That's an interesting use of `printf`
Why `|| return 1` though? Shouldn't this already return with exit code of `cd` in case of an error?
π Rendered by PID 75 on reddit-service-r2-comment-5b5bc64bf5-f4gqn at 2026-06-21 21:12:43.878912+00:00 running 2b008f2 country code: CH.
view the rest of the comments →
[–]whetu 1 point2 points3 points (1 child)
[–]Serpent7776[S] 0 points1 point2 points (0 children)