You are not logged in.

#1 2020-06-17 10:44:51

Beholded
Member
From: /forum/newbie_corner
Registered: 2020-06-03
Posts: 3

[SOLVED] Hidden(?) console commands.

Greetings.

I did not find the answer on wiki, google and on the forum (maybe it exists, specify the link).

When setting up the environment for work, I found commands:

">>" write at the end of the file
example
user]# echo 'alias ls=lsd' >> .bashrc #correct input, in .bashrc new line "alias ls=lsd"
user]# echo 'alias grep='grep --color=auto'' >> .bashrc #incorrect input, in .bashrc new line "alias grep=grep --color=auto", fix - edit string by hands "alias grep='grep --color=auto' "

"!!" insert the last command entered
example
$ systemctl enable dhcpcd
Failed to enable unit: Access denied #oh no.
$ sudo !!
sudo systemctl enable dhcp #shows the line being executed.
$ #end without error.

accidentally wrote "sudo systemctl "| grep dhcp "and got the output:
[User@Pc ~]$ sudo systemctl "| grep dhcp
> #nothing happens with input. pressing enter starts a new line.
>
> ^C #ctl+c stop this.

When i press the up arrow, it displays everything entered in the form of consecutive lines.
If remove the " character from the initial line and press enter, it executes all the entered lines.


Question : where i can find all of this cool stuff (commands like >>, "|, !!, >, etc.), systematized and explained (like how to make ">>" command write symbol ' )?

Last edited by Beholded (2020-06-18 07:30:00)

Offline

#2 2020-06-17 10:57:59

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 15,403

Re: [SOLVED] Hidden(?) console commands.

Most of those (not sure about !!) are not commands.

| is called pipe , while > and >> are for redirection of input/output .

https://ryanstutorials.net/linuxtutorial/piping.php seems to give  a good basic description (in my opinion).


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#3 2020-06-17 10:59:01

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,376

Re: [SOLVED] Hidden(?) console commands.

You are looking for shell built-ins. What is available here differs from shell to shell, assuming you didn't change the default and use bash you will want to read

man bash

for the official documentation, otherwise these two guides/wikis contain a few good snippets and explanations:

https://mywiki.wooledge.org/BashGuide
https://www.tldp.org/LDP/Bash-Beginners-Guide/html/

Online

#4 2020-06-17 11:00:25

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 13,653
Website

Re: [SOLVED] Hidden(?) console commands.

Question : where i can find all of this cool stuff (commands like >>, "|, !!, >, etc.), systematized and explained (like how to make ">>" command write symbol ' )?

Search engines and manpages. What you are describing is 'redirection' and 'history expansion', but any 'basic linux shell usage' search should give you a good run down of them.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#5 2020-06-17 11:20:39

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,237
Website

Re: [SOLVED] Hidden(?) console commands.

Here's an article I recently came across with a list of these kinds of this: https://zwischenzugs.com/2020/05/09/som … bash-tips/

Offline

#6 2020-06-17 12:01:11

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,518
Website

Re: [SOLVED] Hidden(?) console commands.

fukawi2, none of the OPs questions are about obscurities, but rather very basic fundamentals of POSIX shells (and one bashism).

Beholded, please take some time to learn about linux/unix shells if you intend to use arch.  I'd recommend starting with these:
https://ryanstutorials.net/linuxtutorial/
https://ryanstutorials.net/bash-scripting-tutorial/

For one of the cases, there's no need to assume that two characters together are a special command.  The result you saw with "| was just due to the quote.  The pipe was irrelevant - it just ended up being the first character in a string.  The command line parser was waiting for the closing quote to finish the command.

Last edited by Trilby (2020-06-19 02:01:09)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#7 2020-06-17 13:30:39

Beholded
Member
From: /forum/newbie_corner
Registered: 2020-06-03
Posts: 3

Re: [SOLVED] Hidden(?) console commands.

fukawi2 wrote:

Here's an article I recently came across with a list of these kinds of this: https://zwischenzugs.com/2020/05/09/som … bash-tips/

a little too deep, but now i have more questions...

Thank all, understand what just found Bash.

Offline

#8 2020-06-17 21:42:09

bulletmark
Member
From: Brisbane, Australia
Registered: 2013-10-22
Posts: 714

Re: [SOLVED] Hidden(?) console commands.

fukawi2 wrote:

Here's an article I recently came across with a list of these kinds of this: https://zwischenzugs.com/2020/05/09/som … bash-tips/

Geepers, I've been shell programming for very many years but there are a few things in there that I have never seen before!

Offline

#9 2020-06-19 01:26:12

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,237
Website

Re: [SOLVED] Hidden(?) console commands.

bulletmark wrote:

Geepers, I've been shell programming for very many years but there are a few things in there that I have never seen before!

fc was my favorite from that list. Never knew that before.

Offline

#10 2020-06-19 02:00:02

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,518
Website

Re: [SOLVED] Hidden(?) console commands.

I never used fc, but I did use vi mode (`set -o vi`).  With vi mode in BASH you can edit any command in EDITOR my just hitting 'v'.  So I'd just <up>, <esc>, 'v'.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

Board footer

Powered by FluxBB