What does means in linux command

What does + mean in the bash `-exec command <> +`?

It never say something on + ,What does + mean in the bash -exec command <> + ?
It means to terminate the argument such as ; ?
+ means plus such as 3+5=8 or concatenate , to join two strings into one such as s1 + s2 .
It is a strange thing to assign a meaning terminate the argument for + .

This was quite well explained over at SO Prime here, stackoverflow.com/questions/6085156/… And at Unix SE here, unix.stackexchange.com/questions/195939/…

1 Answer 1

It has nothing to do with Bash, it’s a part of find syntax. The command has to know where the -exec action ends. It ends at ; or at + . Depending on the terminating character, a proper variant of -exec action is used.

Why were these two characters chosen for this purpose? I don’t know. Some way to end -exec statement was a must and somebody chose ; and + . Now the characters are parts of POSIX standard when it comes to the find command.

We can only guess that ; was chosen because it can also terminate a command in a shell, so the purpose is similar. For this reason, however, ; that needs to be seen by find has to be treated specially in the shell, hence \; ( ‘;’ or «;» also works). There’s no such problem with + .

Technically almost any other string could have been chosen instead of + (the same with ; ). Note that -exec , <> , + and ; (after it passes the shell thanks to escaping or quoting), possible tests or actions like -type or -print – they all are arguments to find ; they become meaningful when find processes them, their meaning comes from how find was invented.

  1. It’s about find , not about bash .
  2. The tool supports two slightly different -exec actions.
  3. To tell them apart we use two different arguments that terminate -exec statement; it’s a design choice.
  4. These two different arguments are ; and + ; it’s a design choice.
  5. These choices could have been made differently. Even if there is a story behind + (which I don’t know), it’s trivia, not something really meaningful. I can only speculate <> + is for «one argument or more» like 10+ sometimes means «ten or more».

Broader insight

+ means plus such as 3+5=8 or concatenate , to join two strings into one such as s1 + s2 . It is a strange thing to assign a meaning terminate the argument for + .

> means «greater than»… It is a strange thing to assign a meaning «redirect» for > .

» + means plus» is not from God. Somebody decided, others followed and the symbol stuck.

  • Somebody decided + means «plus» in mathematics.
  • Somebody decided > means «greater than» in mathematics.
  • Somebody decided > redirects in a shell.
  • Somebody decided + terminates -exec in find context.

Источник

What Does ./ Mean In Linux ?

What Does ./ Mean In Linux ?

For all the console enthusiasts ./ may seem quite familiar. It’s one of the many great things about Linux that makes it effortless to use from the terminal.

Читайте также:  Работа с txt linux

If you do not know what ./ means, we have got you covered. This article will explain in detail what does ./ in Linux means and what does it do in the Linux system.

Meaning of ./ to the point

The simple meaning of ./ is ‘Current Directory‘. It is as simple as this. But wait, it has more useful and interesting dimensions to it.

For all console enthusiasts, the small details in this ./ symbol, are very important and specific with the user hierarchy which may go unnoticed many times by a novice Linux user.

At any time when you are using Linux from the command line, you are located somewhere on the file system hierarchy. When you are working as a non-root user you are most probably located in your home directory.

Irrespective of what your current directory is you may require to handle files that are located outside your current directory. So changing the directory from time to time may be a tedious job. In order to make this easier, using ./ can prove to be an effective way to handle and modify multiple files from your current directory. You need not change the directories multiple times which will be a time saving and productive method.

Understanding ./ in pieces

Let’s try to understand the meaning of ./ in separate segments of . (dot) and / (slash).

. (dot):- With context to the question we are discussing in this article, the . (dot) simply means the ‘Current Directory of the User‘.

gauravv@ubuntu:~$ ls -al total 179572 drwxr-xr-x 86 gauravv gauravv 266240 Sep 12 09:10 . drwxr-xr-x 4 root root 4096 Sep 4 18:29 .. drwxr-xr-x 2 gauravv gauravv 65536 Jul 15 2018 100CANON 

In the above code, in the highlighted line you can see the dot (.) at the end. This means that this is my current directory.

/ (slash):- When we append a / (slash) to the . (dot) it simply makes sure that you are not operating on a file. It is same as appending / to any other directory name.

Understanding ./ with an example

Let us take an example and understand the ./ with more clarifications.

Let’s suppose you wish to use the nano text editor (a text editor for the console) instead of the Graphical text editor. You will be working on the console completely. When you start working with the editor you are placed in the Home Directory by default.

But suppose if the document that you wish to edit is in another directory. There’s a directory named space and here lies your document cool.txt. So the location path of this cool.txt file becomes ‘/home/gaurav/space/cool.txt‘.

To open this file in nano , you certainly could type cd [Directory_name_where_file_located] and then nano cool.txt .

But to make it more efficient and easy we can merely type nano ./space/cool.txt .

Look at the outputs below to better understand the example.

gaurav@ubuntu:~$ pwd /home/gaurav gaurav@ubuntu:~$

Here the Home Directory is ‘/home/gaurav‘. And the file to be edited (cool.txt) is located at ‘/home/gaurav/space‘.

Читайте также:  Посмотреть переменные окружения линукс

But let’s say that I do not wish to change my current directory (/home/gaurav) and directly work from my home directory. I’ll do it as follows.

gaurav@ubuntu:~$ nano ./space/cool.txt GNU nano 2.9.3 ./space/cool.txt Modified Hi my name is tony stark i am a superhero.
gaurav@ubuntu:~$ cat ./space/cool.txt Hi my name is tony stark i am a superhero. gaurav@ubuntu:~$ 

Here I edited the file from my home directory itself without changing the path.

The main advantage of using ./ is that if you don’t wish to navigate away from your current folder, you can still manipulate files around you.

If you had typed only nano cool.txt , you would be commanding nano to open a file on the home directory (/home/gaurav) it would return an error as the file doesn’t exist in the home directory. And that’s the reason you use nano ./space/cool.txt

Executing programs with ./

./ can be used to run the executable files of a program. We will understand this with an example.

If I want to run a C program in my $PATH (use echo $PATH command to get your PATH), I’ll just compile the C program. On compilation, an executable file named a.out will be created in the current directory. To execute this program I shall run the executable file a.out . In order to run this C program, I shall just type ./a.out to execute the C program.

gaurav@ubuntu:~/space$ sudo gcc demo.c [sudo] password for gaurav: gaurav@ubuntu:~/space$ ./a.out gaurav@ubuntu:~/space$ 

In this context, prepending the command with ./ effectively says “forget about the PATH, I want you to look only in the current directory”.

Similarly you can instruct the system to look only into another specific location by prepending the command with a relative or absolute path such as:

../ means Parent Directory or ./work/demo.c which means that look for the file demo.c in the directory named work.

Conclusion

“ ./ “ is used in a pathname to indicate the current directory. It can also run a script from the current working directory. It’s a time saver practice to use ./ in your $PATH as it enables you to modify files that are not present in your current directory and that too without even leaving your current working directory.

Источник

What does ./ mean in Linux?

The terminal of the Linux system is a command-based user interface. You provide your commands into the terminal, and the shell then executes your command and performs the task your command specified.

Many a time, while running some command, you may have observed the ./ present. However, you couldn’t figure out what does the ./ mean. Here we’ve explained what does the ./ mean in the Linux systems and where it’s used.

Meaning of ./ in Linux

To understand the meaning of ‘./’, let’s break it into ‘.’ and ‘/’.

The ‘.’ means the present working directory where you are right now.

The ‘/’ means that you are looking for a directory and not working for a file.

Читайте также:  Astra linux файл репозитория

Therefore ./ means inside your current directory.

The meaning of ./ in Linux screenshot - 1 | What does ./ mean in Linux?

The ‘ls’ command gives the list of the files and directories present in your current working directory unless some specific directory name is given to it.

As we can see in the image above, the present working directory is ‘Candid.Technology’. When we do a ‘ls -l’ we can see the contents of the directory ‘Candid.technology’. Now, when you give the command ‘ls -l ./’, the output displays the contents of the Candid.Technology directory.

Thus, the ./ refers to nothing else but the current working directory.

Where ./ is used in Linux?

The ./ is generally used to specify the file path or the directory path in a relative way. Let’s understand the example given below to gain more insights.

What does ./ mean in Linux?

As you can see in the image above, the present working directory is Candid.Technology. Now, you want to copy a file ‘Hello.txt’ from the home directory to a directory ‘example’ present inside your current directory without changing your current working directory. Here, you can use the ‘./’ to specify the file path.

The path ‘./example/Copied_Hello.txt’ specifies that there is a directory called example in the current working directory (./), where you need to copy the Hello.txt file as Copied_Hello.txt. Thus, by using ‘./’, you specified the relative path for the destination of the copied file, and your current working directory also remained the same.

Therefore, you can use ‘./’ in Linux to specify your current working directory and use it in relative paths to use some files without changing the current working directory.

Источник

What does «|» mean in a terminal command line? [closed]

Sorry for posting it here, but Google does a very bad job when searching for symbols. What does the «|» mean in:

"some string" | someexecutable.py 

The bash man page explains the behaviour in great detail — is there something you didn’t understand there?

3 Answers 3

It is the pipe symbol. It separates two programs on a command line (see Pipelines in the bash manual), and the standard output of the first program (on the LHS of the pipe) is connected to the standard input of the second program (on the RHS of the pipe).

gives you a count of the number of people or sessions connected to your computer (plus one for the header line from who ). To discount the header line:

The input to sed comes from who , and the output of sed goes to wc .

The underlying system call is pipe(2) used in conjunction with fork() , dup2() and the exec*() system calls.

Note that when it is combined with other characters, the | symbol has different meanings. In ‘all’ shells, || is a logical connective. It executes the first command; if it exits with a non-zero (failure) status, it executes the second command too. In Bash (and maybe some other shells), |& is a variant of | that sends standard error as well as standard output to the next command in the pipeline. Sometimes, interpreting a sequence of symbols is hard ( ls|html mapper probably doesn’t do what you might think).

Источник

Оцените статью
Adblock
detector