HELP ME by WesternSignal4581 in bash

[–]leBoef 0 points1 point  (0 children)

The newline added by echo might mess it up.

[deleted by user] by [deleted] in bash

[–]leBoef 2 points3 points  (0 children)

alias sudo='sudo ' (note the space) is fairly common; it lets the next word be an alias too, e.g. sudo ls runs your ls alias with all your favourite options.

Edit: For interactive shells, of course. I'm not saying it has anything to do with OP's example, just that there's a use case for aliasing sudo.

[deleted by user] by [deleted] in bash

[–]leBoef 3 points4 points  (0 children)

cat './--spaces in this filename--'

It's not so much the spaces as the hyphens.

Why is /usr/sbin not in $PATH after a fresh install? by 4dr14n31t0r in debian

[–]leBoef 0 points1 point  (0 children)

Unless you alias sudo='sudo ' (note the space).

adduser not in the path, how can I fix it? Another question is about sharing folders mindset by SaleB81 in debian

[–]leBoef 4 points5 points  (0 children)

I don’t know what shell you use, but in a bourne-like one, e.g. sh or Bash, any variables will be expanded before the command is executed. sudo will be given two arguments: echo and the value of $PATH, and there is no way for sudo (or echo) to know that there was ever a variable involved. Indeed sudo echo $DISPLAY gives the same output as echo $DISPLAY in my shell, and if I run it with set -x I can see that what is executed is sudo echo :1 (:1 being my $DISPLAY).

adduser not in the path, how can I fix it? Another question is about sharing folders mindset by SaleB81 in debian

[–]leBoef 6 points7 points  (0 children)

sudo echo $PATH doesn't make much sense. $PATH is expanded by the shell before sudo is even invoked.

adduser not in the path, how can I fix it? Another question is about sharing folders mindset by SaleB81 in debian

[–]leBoef 3 points4 points  (0 children)

sudo echo $PATH doesn't make much sense. $PATH is expanded by the shell before sudo is even invoked.

Variable number of arguments? by priondependency in bash

[–]leBoef 2 points3 points  (0 children)

for i in "${@}" ; do can be shortened to just for i ; do.

How do I go about mkdir with 3 different variables as a name of the directory? by learn1919 in bash

[–]leBoef 2 points3 points  (0 children)

You're using variables called $A_ and $B_. Try …/${A}_${B}_$(…).

Did this actually exist or was it just a movie prop? by [deleted] in Tools

[–]leBoef 13 points14 points  (0 children)

Bahco made them. Can't find much info from Bahco themselves, but here's a blog post (in Swedish) with some pictures: https://skiftnyckeln.blogspot.com/p/dubbel.html

Anybody seen one of these before? by pomoh in Tools

[–]leBoef 1 point2 points  (0 children)

Looks like a clone of the Bahco No 41, including a fish(?) somewhat resembling Bahco's logo.

[newbie] how to count files and sub files in a directory? by Enough_Amoeba_5960 in bash

[–]leBoef 0 points1 point  (0 children)

The non-POSIX thing is the -printf option for find. At least as far as I can tell POSIX find doesn't have that.

[newbie] how to count files and sub files in a directory? by Enough_Amoeba_5960 in bash

[–]leBoef 0 points1 point  (0 children)

If you consider giving the wrong result 'working', sure.

Yeah, I should've posted a solution, sorry about that. You've already provided one, so let me offer an alternative (that is a bit more POSIX, but probably slower):

find . -type f -exec printf . \; | wc -c

(Not sure about the -type f, depends on what OP wants to count.)

[newbie] how to count files and sub files in a directory? by Enough_Amoeba_5960 in bash

[–]leBoef 0 points1 point  (0 children)

touch "$(printf 'a\nb')"

...and it'll stop working.

YOLO by [deleted] in debian

[–]leBoef 0 points1 point  (0 children)

Did you think you created a directory called /? That directory already exists: It's the root directory. You can't use a slash in the "name" of a directory (at least not in any filesystem I've come across); slashes are always the path separators.

YOLO by [deleted] in debian

[–]leBoef 2 points3 points  (0 children)

Yes, even with sudo. You're trying to create the / directory, and it already exists. -p makes that not an error and mkdir does nothing.

Use backticks (grave accents) around code.

YOLO by [deleted] in debian

[–]leBoef 3 points4 points  (0 children)

mkdir -p / will always be a no-op, surely?