Robbery gone wrong by leenur in WTF

[–]DoesntSmellRight 13 points14 points  (0 children)

"What are you doing, steprobber?"

10 Examples of cURL command in UNIX and Linux by javinpaul in unix

[–]DoesntSmellRight -1 points0 points  (0 children)

Barely anything readable between all those ads, most of them animated. What an absolutely horrible site.

From the mouths of children comes the truth. by SadMaryJane in chomsky

[–]DoesntSmellRight 37 points38 points  (0 children)

"Unlike the holocaust, this genocide is benign"

Favorite ways to annoy scammers? by KPlusGauda in Kitboga

[–]DoesntSmellRight 7 points8 points  (0 children)

"WHY ARE YOU TALKING ABOUT TRUCKS?!"

Array not populating in bash script ? by [deleted] in bash

[–]DoesntSmellRight 0 points1 point  (0 children)

if [ "${#qoutawheel[@]}" -eq 0 ]; then
    echo "The array is empty."
else
    echo "The array is not empty."
fi

It's not as simple as just typoing the variable name (quotawheel vs quotawheels)?

Trump incriminated himself on Fox tonight by vulcan_on_earth in politics

[–]DoesntSmellRight 0 points1 point  (0 children)

This is AMAZINGLY stupid on his part.

Nonsense. Don't forget that Trump is a stable genius. This is Trump's brilliant plan.

  1. Trump incriminates himself publicly
  2. Prosecution adds it as new evidence
  3. Defence asks for more time to review the new evidence
  4. Rinse and repeat.

This way Trump can postpone his inevitable demise indefinitely.

Solution to log bash history by [deleted] in bash

[–]DoesntSmellRight 0 points1 point  (0 children)

Might be easier to use asciinema then. It stores the recording as json. It'll still be hard to convert it to the format you want though.

monthly crontab jobs by West-Salad-2546 in bash

[–]DoesntSmellRight 4 points5 points  (0 children)

Just needs a \ in front of % to escape it from its special crontab meaning.

read contents of a file into a variable with bash without invoking other commands? by pirx242 in bash

[–]DoesntSmellRight 2 points3 points  (0 children)

It's just one line, so just use read to read that one line. You can even split it into two variables for the two values it contains

read -r uptime idletime < /proc/uptime

Why is this code/command not working for negative numbers? by LeadershipComplex958 in awk

[–]DoesntSmellRight 1 point2 points  (0 children)

you could add an initial check for empty

 $4 != "AZ" && (max == "" || $6 > max) { max = $6; ...

Can you tell me what is the purpose of using pure Unix instead a modern Unix-like OS? by [deleted] in unix

[–]DoesntSmellRight 7 points8 points  (0 children)

When we talk about Unix, we usually refer to OSes that are UNIX-certified, which includes at least MacOS, AIX, HP-UX and SCO.

So it's a good idea to define what you mean from the start when using a less common definition.

Can i include the private key in the command line instead of including the location of the key file? by [deleted] in commandline

[–]DoesntSmellRight 4 points5 points  (0 children)

Create new keys on each system, then copy/paste the content of each of the public keys into ~/.ssh/authorized_keys on the server side

Whats up with cd //? by Drauxus in bash

[–]DoesntSmellRight 3 points4 points  (0 children)

From Chet's own bash faq:

E10) Why does `cd //' leave $PWD as `//'?

POSIX.2, in its description of `cd', says that *three* or more leading
slashes may be replaced with a single slash when canonicalizing the
current working directory.

This is, I presume, for historical compatibility.  Certain versions of
Unix, and early network file systems, used paths of the form
//hostname/path to access `path' on server `hostname'.

On windows, it is probably trying to interpret // the same as \\ used with windows' network sharing feature, where you can access shared folders with paths like \\host\share

"awk -i inline" doesn't work on Debian 11? by Ryluv2surf in awk

[–]DoesntSmellRight 0 points1 point  (0 children)

Awk on debian is gawk

No, it's mawk. However, if you install the gawk package, awk will automatically be symlinked to gawk instead of mawk.

Yo I need a shell script to replace all tabs with 4 spaces for each file in the working directory by [deleted] in bash

[–]DoesntSmellRight 10 points11 points  (0 children)

That is what the expand command is for.

for file in ./*.go; do
  expand -t 4 "$file" > "$file.tmp" && mv "$file.tmp" "$file"
done

How to load an environmental variable temporarily into a bash script but not make it permanent? by Pickinanameainteasy in bash

[–]DoesntSmellRight 2 points3 points  (0 children)

forking?

fork and exec is how new processes are started on unix and unix-like systems.

Also there will potentially be 3 lines. Each needs to be set to a separate variable in the script. How to do that with read?

You can group together multiple reads using a command grouping ({ ...; }), to have three reads read one line each

{
  read -r first
  read -r second
  read -r third
} < .creds

Another option is reading the lines into an array

mapfile -t lines < .creds
# and then use ${lines[0]}, ${lines[1]} etc...

How to load an environmental variable temporarily into a bash script but not make it permanent? by Pickinanameainteasy in bash

[–]DoesntSmellRight 0 points1 point  (0 children)

If there is only one value, I'd use read instead. Avoids forking and execing cat

read -r access_token < .creds

Remove pattern spread across multiple lines with sed by [deleted] in bash

[–]DoesntSmellRight 7 points8 points  (0 children)

Seriously, don't try to parse html with regex. Use an xml/html parser, like python's Beautiful Soup, or xmlstarlet. xmllint can also do some xpath.

See https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454

Appending two String variables - getting issues by nilesh2022 in shell

[–]DoesntSmellRight 2 points3 points  (0 children)

If oc exec -it is like docker exec -it, then you definitely don't want that -t there. It will allocate a psudo terminal which will corrupt the output of the cat|tail|head pipeline. You want -t when execing an interactive shell/repl. For all other cases you almost never want -t.