Most voted "bash" questions
Bash is a very popular shell (command interpreter). Using the commands provided by Bash itself (built-in Commands) we can perform a series of operations in sequence or create quite complex scripts/programs.
Learn more…291 questions
Sort by count of
-
3
votes1
answer58
viewsCheck that process is running without bumping into the 15-character limit
With the following code we check if a process is running: #!/bin/bash #Verificar se processo abc está em execução if pgrep "abc" >/dev/null 2>&1 then printf "Está em execução.\n"…
-
3
votes1
answer1222
viewsCalling another terminal with python
I’m doing a project here and I need to open another terminal window, which runs the command ls. I’ve tried with subprocess but it was a mistake: Traceback (most recent call last): File "tests.py",…
-
3
votes1
answer307
viewsHow to remove an alias in bash?
No bash, how to remove an alias? For example, after doing alias man="man -a", I just want to execute man instead of man -a.
-
3
votes1
answer753
viewsRegular expressions with grep
I need to extract data from a text and I’m trying to do this using grep. But the way to make use of regular expressions with this command is quite different from what is usually done in Ruby or…
-
3
votes0
answers889
viewsLinux Script - Find, Copy, Paste and Change Text Files
I have these 3 files: Access.txt: Large text file with row records and columns separated by " ; ". NewAcess.txt: List of new accesses to add. NewUsers.txt: List of new users to add. File Example:…
-
3
votes2
answers97
viewsWhat does the expression "for x in *" do?
I saw this expression in a SOEN question, but I did not understand very well what it does for x in *; do echo $x; done This printed the folder list of the directory I was in. That’s what that…
bashasked 9 years, 2 months ago Wallace Maxters 102,340 -
3
votes2
answers108
viewsScript to open index.html from multiple folders
How to make a script in bash that: Based on this example url: http://www.exemple.com.br/1/43530/12620/index.html Select the folder 12620. Open the index.html of this folder in a Firefox tab in Kali…
-
3
votes3
answers7306
viewsCheck if a process is not running and then run it
I need to run a certain command via terminal. However, this command should only be run if the terminal process is not running. If it is running, there is no need to do any other operation. How to do…
-
3
votes4
answers684
viewsVariable interpolation in shell script that returns the output of a function
I isolated a problem from a larger script that I am producing. I basically have a function that returns the current date and time in a specific format. I need every time the variable data_hora is…
-
3
votes3
answers2128
viewsSend PHP variable to Shell Script
I have a file .sh and it has variables that I need to receive from PHP, follow an example: //variavel 1 que preciso receber externamente NAME="" //variavel 2 que preciso receber externamente DIR=""…
-
3
votes1
answer1339
viewsAutomate enter input in command line while running a bash script
I created a script in bash to automate the installation and configuration of my environment necessary to run my project, but some of the tasks require that the actions are confirmed giving enter, I…
-
3
votes1
answer208
viewsConversion of timestamp epoch file name to date
Expensive; I have a list of files (140 thousand) with date in the format Unix epoch timestamp in the file name. I need to convert each file to match its actual date by changing its name. Example:…
-
3
votes3
answers494
viewsExtract information from a.txt file
I have a.txt file with the following information. 31.812:9.862 179.52:6.847 315.015:9.135 462.305:6.276 103.875:4.122 176.064:3.593 196.7:4.407 246.599:4.423 And I need to extract that information…
-
3
votes2
answers259
viewsProblems with bash - echo with char ! (exclamation)
I’m trying to pass a password as parameter the password uses numbers after char ! example: root@LinDom:~# senha="teste!123" senha="testevim /etc/hosts" root@LinDom:~# root@LinDom:~# echo ${senha}…
-
3
votes2
answers1773
viewsHow to make code include in Shell Script files
How can I perform the following process: Add the arquivoa.sh and arquivob.sh in the arquivoc.sh, and then perform the defined functions within each file archivoa.sh #!/bin/bash echo "Arquivo A"…
-
3
votes1
answer1865
viewsStore user logged in variable . bat
I have to create a bat to automate the installation of the company’s standard programs, but one specific is giving me a headache. The installer of one of the programs by default creates the path C:…
-
3
votes1
answer368
viewsChecklist and Dialog with external file - Shell Script
I need to use the Dialog making a Checklist from an external file, I have so far done the following: dialog --stdout --checklist "Contas de e-mail: " 0 0 0 \ while read line do $line "" on \ done…
-
3
votes1
answer154
viewsbash - How to prevent malicious code execution via input?
I own a script (script.sh) who receives a environment variable: echo $MINHAVARIAVEL But when calling it via terminal, I realized that I can pass commands through this variable, and these commands…
-
3
votes1
answer419
viewsHow to list containers in Docker?
I recently started testing on Docker, created a virtual machine and installed Debian 9 without a graphical interface. I know the command: docker ps Shows the running containers, there are other…
-
3
votes1
answer49
viewsMaximum memory consumption on linux bash using openssl with aes
#!/bin/sh SUM = 0 for i in {1..5} do t=$((/ usr / bin / time-f '% e' openssl enc -aes-128-ecb -K 1234567890 -in t -out g 1> /dev/null) 2> &1) SUM = `bc <<<" $ SUM + $ t "` done…
-
3
votes2
answers902
viewsIgnore the first line
I am using the following command to organize a file: sort -u arquivo.csv -o arquivo.csv But I need to ignore his first line, in case the header. How can I do that?…
-
3
votes2
answers4327
viewsHow to compare the value of a variable to a string in the shell script
Well, I’m trying to make a comparison like this but bash is playing it like a command if "$V1" = "sim" then ... how I compare the value of V1 to the string "yes":…
-
3
votes2
answers685
viewsFix invalid command dynamically, no alias required
I’m using GNU bash version 4.3.46. One problem I have when typing commands, is that I often end up forgetting a space between the command and its parameters. Examples: cd.. gitlog When the right…
-
3
votes1
answer55
viewsHow to scan a linux file based on creation time?
I am mounting a backup script and need to create a scan to analyze if any file in a folder was created in the last 7 days, what is the path to it? I know the command ls -lt lists the files in the…
-
3
votes1
answer79
viewsHow do a script accept bash script completion?
Let’s say I have a script that asks for a user input as shown below Digite o caminho do arquivo: How do I make this input autocomplete the directory path in linux? I need this to avoid typos…
-
3
votes2
answers2051
viewsAuthentication error sending file to repository on Github
Well, I followed that one link, but when I get to git push -u origin master it asks for the git user and password in a windows Forms, then asks the user (2 line), and asks for the SSH password and I…
-
3
votes1
answer91
viewsDiff changing lines
I’m comparing two files, which are updated daily, with the command diff -y in order to obtain two results: The first are the lines that have been modified overnight:…
-
3
votes1
answer49
viewsretrieve date from bash Ubuntu
I am mounting a scrip to dump a Mysql server, the name of the generated file is like this (bckp_all_13-09-2018.tar.bz2), but I wanted to store the time too, so…
bashasked 6 years, 2 months ago Hugo Borges 5,294 -
3
votes2
answers396
viewsHow to create a shell script that puts an echo at the beginning of each line in a file
I need to create a script that inserts the echo command at the beginning of each line of the file and at the end >> blocodenotes, for example #!/bin/bash ls -l uname -a netstat -tunap I want a…
-
3
votes4
answers249
views -
3
votes1
answer67
viewsHow to count the lines of an output in the terminal?
I want to count the total outputs of the results in the terminal. For example using the cat lista_de_compras.txt: arroz feijão leite I want to receive 3…
-
3
votes3
answers117
viewsHow to identify output status in a bash program?
I have a bash that runs a series of scripts in other languages. When I step from one script to another I use the first form of conditional (&&) which I understand as "run the next script if…
-
2
votes3
answers579
viewsDelete . bashrc, . bash_profile and . profile files: what are the consequences?
I’ve been trying to install the Ruby and the Ruby on Rails through the RVM but during the installation process I had some problems. I tried to uninstall the RVM through the commands : rvm implode…
-
2
votes2
answers89
viewsAlternative energy in Bash
I am trying to get a part of a line in bash text files but instead of the text'field1 'I wanted to use a variable. But it is not working. Suggestions WORKS: NomeVar=$(cut -d ":" -f 1 <<<…
bashasked 9 years, 10 months ago Pedro Caldeira 23 -
2
votes1
answer1179
viewsCheck if user exists
How can I in bash check if a user exists, but in such a way that script work in multiple systems ? A limited example: grep <username> /etc/passwd Does not work on systems that use NIS or LDAP…
-
2
votes2
answers2125
viewsCopy (cp) to current folder on LINUX
It is possible to display destination path by giving a command to copy (cp) from the linux console to the current/current folder? Ex: cp ~/Origem ~/Destino What I desire is some shortcut in bash…
-
2
votes1
answer331
viewsComputer Date and Language Shell Script
Is there any shell script function that takes the date and time (time zone) and language that are configured on the computer?
-
2
votes1
answer292
viewsInsert text using FFMPEG, but only in a video snippet
I use the code below to generate new videos (from the respective folder) by inserting the name and CPF of the student in each video. However, this way, the compilation takes a long time, since the…
-
2
votes2
answers58
viewsError using alias and read in Shellscript
I’m trying to create a command on. Ubuntu bashrc, however I’m having a problem, I’m trying to create a folder with the variable typed when calling the alias, but it’s giving error. When I open the…
-
2
votes1
answer5102
viewsHow to list the symlinks of a folder on Linux?
I’m using a tool to deploy in PHP. When I use the command, some symbolic links are created for certain folders. As I will run this command on a Linux server, I wonder if there is a command to list…
-
2
votes1
answer91
viewsInstalling Mysql on linux programmatically. How to set the password?
I am creating a sh file to start a Linux programming environment to automate this boot process. I usually only run the following command lines and during the Mysql installation process I have to…
-
2
votes2
answers1017
viewssyntax error near Unexpected token `fi' Linux
I’ve been trying to make a code to automate the steamcmd but always gave me this mistake syntax error near Unexpected token `fi', someone could help me? Code:…
-
2
votes1
answer504
viewsinsert bash commands into expect
Good evening guys, I have an activity to do that I needed to use Expect to remove user interaction in an SMTP communication. Only that in the body of the email I need to add the current date and the…
-
2
votes3
answers507
viewsTransform date format DD/MM/YY into MM/DD/YY into Shell Script
The script reads the date of a . txt in DD/MM/YY format, and I need to convert it to MM/DD/YY format with Bash, Sed or AWK.
-
2
votes1
answer472
viewsHow to sort a column of a file without ordering the rows?
I have a file that has three columns, and several rows. The second column is composed of numerical values, and I want to reorganize it, in ascending order, but without affecting the previous column…
-
2
votes1
answer522
viewsCompare files from a directory with md5sum and shellscript
Good morning! I am studying shellscript and an exercise asks for a scan of files in the current directory and to calculate the md5 hashes. It also asks that, in case there are identical files by…
-
2
votes2
answers1758
viewsI can’t clone repository with git bash
I wonder why I can’t clone a public Github repository with git bash. I give the command git clone plus ssh or https, but gives the following message: Permission denied (publickey). Fatal: Could not…
-
2
votes1
answer760
viewsBash alias with parameters
I am creating a system that works online, the user logs in and will have access to a terminal that it can execute only the commands allowed on the server. That’s the thing about: The user will have…
-
2
votes1
answer1671
viewsShell Script for file and directory localization
I wish someone could help me to create this script correctly, in this case it is to create a script that Oce type the name and directory of a file and then indicate whether it was located or not and…
-
2
votes1
answer505
viewsHow to call a function within a PHP script from the command line
I want to know if I can call a function inside a script from the command line, using for example: $ php script.php minhaFunção() <argumento> in the case, the function is not within a class (it…