logo
down
shadow

BASH QUESTIONS

Find Directories with particular tree structure
Find Directories with particular tree structure
This might help you I want to find directories in the file system which has a particular tree structure. , The following seems to work:
TAG : bash
Date : January 12 2021, 09:11 PM , By : Edo
How to stop $ / being stripped of a string being inserted into a file with sed?
How to stop $ / being stripped of a string being inserted into a file with sed?
it helps some times The Aim I am trying to write a bash script to automate the setup of a Raspbian system. This includes setting a custom prompt for all users. I need to change one line in the /etc/bashrc file. , So, the following works:
TAG : bash
Date : January 12 2021, 07:00 PM , By : user150744
Compare lines of a 'specific' column and join the other columns if the lines of the 'specific' colum match
Compare lines of a 'specific' column and join the other columns if the lines of the 'specific' colum match
help you fix your problem One way using the ever-useful GNU datamash plus some massaging to get the output in the format you want:
TAG : bash
Date : January 11 2021, 03:28 PM , By : user186435
How do I recursively append a unique identifier to a series of identical strings in bash?
How do I recursively append a unique identifier to a series of identical strings in bash?
seems to work fine I want to extract the line for each instance of the strings and print them to new files (so the line from first instances of string_9989 and string_1234 to 1 file, second instances of each to another file, etc)
TAG : bash
Date : January 11 2021, 03:26 PM , By : keird
How to sudo su; then run command
How to sudo su; then run command
it helps some times Unless you have an unusual setup, you can't normally string su with other preceding commands like that. I would imagine it is running sudo su, then hanging in the root environment/session, because it's waiting for you to exit befo
TAG : bash
Date : January 11 2021, 11:39 AM , By : user137798
How to resolve a syntax error of "unexpected token 'then'"?
How to resolve a syntax error of "unexpected token 'then'"?
Any of those help This error is due to the \ present after in the script. A backslash escapes the next character from being interpreted by the shell. If the next character is a newline, then the newline will not be interpreted as the end of the comm
TAG : bash
Date : January 10 2021, 02:04 PM , By : Harry Truman
Bash: Terminate on Timeout/File Overflow while Executing Command
Bash: Terminate on Timeout/File Overflow while Executing Command
I wish this help you There's a GNU coreutil command timeout to do timeouts.Investigate ulimit -f 32 to set the maximum file size (to 16 KiB; it counts in 512 byte blocks).
TAG : bash
Date : January 10 2021, 01:47 PM , By : Antony Briggs
Recursive FTP directory listing in shell/bash with a single session (using cURL or ftp)
Recursive FTP directory listing in shell/bash with a single session (using cURL or ftp)
will be helpful for those in need The command is actually ncftpls -R. It will recursively list all the files in a ftp folder.
TAG : bash
Date : January 10 2021, 01:45 PM , By : user142345
Bash: Conditional Statement Without IF via Grouping Commands and Boolean Operators
Bash: Conditional Statement Without IF via Grouping Commands and Boolean Operators
hope this fix your issue Command substitution starts a subshell (and in this case the captured output would be run as a command, if there were any output). You want a command group.
TAG : bash
Date : January 09 2021, 02:14 PM , By : user176691
How to dynamically define a path using a file prefix within a directory?
How to dynamically define a path using a file prefix within a directory?
around this issue If you just want to get the prefix of the first file in the $abspath you could use something like this:-
TAG : bash
Date : January 09 2021, 05:38 AM , By : August
Track pg_dump process id and trigger an error while it fails
Track pg_dump process id and trigger an error while it fails
will be helpful for those in need You use wait to recover the return code of a background process.See: Bash man-page wait:
TAG : bash
Date : January 08 2021, 10:52 AM , By : Fred Morrison
Multiple commands: do not continue on error
Multiple commands: do not continue on error
I hope this helps . Ouch, this was an easy one it seems (lucky for me). to @Cyrus I added set -e to my ssh commands, then for commands that were allowed to fail just used || true like so:
TAG : bash
Date : January 08 2021, 03:18 AM , By : Arnaud Goudsmit
How to alias a command if the command contains a certain word at the beginning
How to alias a command if the command contains a certain word at the beginning
hop of those help? I need to alias a command started with conda only at the first time. , Replace
TAG : bash
Date : January 07 2021, 03:08 PM , By : waarg
How to use the exit code of netcat command in a if condition?
How to use the exit code of netcat command in a if condition?
wish helps you I think the problem comes down to usage of how you are storing the nc command in a variable to eval it later. When you did
TAG : bash
Date : January 07 2021, 03:08 PM , By : Dave M
How can I take multiple arguments in bash using getopts?
How can I take multiple arguments in bash using getopts?
it fixes the issue Updated at suggestion of Gordon Davisson.You need to include the ':' after both the s and e to signal that those options are expecting arguments.
TAG : bash
Date : January 06 2021, 03:17 PM , By : user109127
Name for ${...} constructs (for strings and arrays) in bash?
Name for ${...} constructs (for strings and arrays) in bash?
Hope that helps Bash allows things like ${string} (string length) or ${array[10]} (indexing array). There's many more forms than the above, for example ones for trimming, replacing, changing case, etc. , These are "parameter expansion" constructs. Se
TAG : bash
Date : January 05 2021, 11:29 AM , By : bjorngylling
How to determine if an EXIT trap is defined for a BASH subshell?
How to determine if an EXIT trap is defined for a BASH subshell?
will be helpful for those in need When Using Bash 3 The answer depends on the version of bash you are using. For example, my Mac, with macOS High Sierra installed, by default uses GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17). In this c
TAG : bash
Date : January 03 2021, 08:18 AM , By : littlefuzz
How can you tokenize a bash string into an array when the string includes a * character?
How can you tokenize a bash string into an array when the string includes a * character?
seems to work fine Let read do it; unquoted parameter expansions are subject to pathname expansion as well as word splitting, so * is expanded to all file names in the current working directory.
TAG : bash
Date : January 02 2021, 06:48 AM , By : Joshua Johnson
Use OPTARG as variable in shell script, no matter the order of arguments
Use OPTARG as variable in shell script, no matter the order of arguments
This might help you suppose I have a script like so: (let's call it test.sh) , Move the "if" logic out of the switch/case:
TAG : bash
Date : January 02 2021, 06:48 AM , By : Sascha Brossmann
Why does my loop occasionally not read the entire line?
Why does my loop occasionally not read the entire line?
it fixes the issue It is preferred to output null $'\0' terminated entries rather than the newline character $'\n'. The -print0 option of the find command does exactly this.Here is your corrected code:
TAG : bash
Date : January 02 2021, 06:48 AM , By : jbcrail
Is there any shorter syntax for changing several directory levels back up with bash cd?
Is there any shorter syntax for changing several directory levels back up with bash cd?
will be helpful for those in need There's no standard way.You can declare a function that takes a number of parent directories as the first argument, and the relative path as the second one:
TAG : bash
Date : January 02 2021, 06:48 AM , By : user181706
Correctly formatting a PYTHONPATH in my .bash_profile
Correctly formatting a PYTHONPATH in my .bash_profile
this will help If it's your wish to be the sole owner and decision maker regarding PYTHONPTAH environment variable content on your interactive login shells, you're doing it right:~/.bash_profile or ~/.profile
TAG : bash
Date : January 02 2021, 06:48 AM , By : Tim Benninghoff
Bash Script : Check if number starts with
Bash Script : Check if number starts with
wish of those help , Remove the $ from the assignment.
TAG : bash
Date : January 02 2021, 06:48 AM , By : Tonix
im getting a syntax error when i run my shell script, the error is in my for each loop and says unespected token `;;'
im getting a syntax error when i run my shell script, the error is in my for each loop and says unespected token `;;'
may help you . Im trying to make a shell script that searches for sketchy processes, prints out a list of the pid and name of the process, asks you if you would like to kill them and then if you say yes goes through and kills each process. here is my
TAG : bash
Date : January 02 2021, 06:48 AM , By : Tetting
Write a shell script that will return the list of files skipped by your repository git
Write a shell script that will return the list of files skipped by your repository git
it fixes the issue I would love some help to write a shell script that will return the list of files skipped by my git repository. , To list all ignored files you can try
TAG : bash
Date : January 02 2021, 06:48 AM , By : August
Create a shell script that returns the last 5 hash of my commits of my git deposit
Create a shell script that returns the last 5 hash of my commits of my git deposit
Any of those help I need to write a shell script that returns the last 5 hashes of my commits in my git deposit. , This should do it:
TAG : bash
Date : January 02 2021, 06:48 AM , By : Ari
How to copy Associative Array without for loop
How to copy Associative Array without for loop
may help you . Just print old values and rename the variable value. Then source it. Ex. like this:
TAG : bash
Date : January 02 2021, 06:48 AM , By : user179938
Extract specific string from line with standard grep,egrep or awk
Extract specific string from line with standard grep,egrep or awk
like below fixes the issue i'm trying to extract a specific string from a grep output , Is this what you're trying to do?
TAG : bash
Date : January 02 2021, 06:48 AM , By : Blight
Copy files that have at least the mention of one certain word
Copy files that have at least the mention of one certain word
hop of those help? Use the -l option to have grep print all the filenames that match the pattern. Then use xargs to pass these as arguments to cp.
TAG : bash
Date : January 02 2021, 06:48 AM , By : lonehunter01
How it exactly works?
How it exactly works?
like below fixes the issue This command line uses curl to download a script from Node's site. It then pipes it in to a new shell executed as root (thanks to the sudo), and the script contains all the actions required for installing Node.
TAG : bash
Date : January 02 2021, 06:48 AM , By : user185144
How to insert a specific character at a specific line of a file using sed or awk?
How to insert a specific character at a specific line of a file using sed or awk?
With these it helps I want to use command to edit the specific line of a file instead of using vi. This is the thing. If there is a starting with the line, then replace the to make it uncomment. Otherwise, add the to make it comment. I'd like to u
TAG : bash
Date : January 02 2021, 06:48 AM , By : Thx1138.6
How to create bash script that combines specified list of items at random?
How to create bash script that combines specified list of items at random?
wish of those help Your comment below the answer indicates you wish to store the shuffled lists within the script itself rather than relying on an external utility. While you could just call the utilities within your script, you can also "house the l
TAG : bash
Date : January 02 2021, 06:48 AM , By : nobodyzzz
How to get the return code from the bash command
How to get the return code from the bash command
seems to work fine I tried to execute the .sh script in macos using the command below. i would like to get the return code form the execution of the command , You can try this:
TAG : bash
Date : January 02 2021, 06:48 AM , By : Nick Coats
Running a bash find with file cp parameter error python script
Running a bash find with file cp parameter error python script
I hope this helps . I think you are missing "\;" at the end. I am not sure what the .* rm does. Assuming you want to remove the files you can use the 'mv' command instead of 'cp'. For copying files only from one directory to another ,
TAG : bash
Date : January 02 2021, 06:48 AM , By : Kim
How to pass a file as an argument to a bash script function?
How to pass a file as an argument to a bash script function?
it fixes the issue As others have said, to get the value of a variable you need to prefix the variable name with the unary operator $. Try to be consistent with your quoting (if in doubt, quote it), and indent code inside functions (and if, while loo
TAG : bash
Date : January 02 2021, 06:48 AM , By : chintown
How can I pass a complex file glob to a subshell?
How can I pass a complex file glob to a subshell?
I hope this helps you . It is probably because of how shell expands the glob string stored in the variable. No matter which quotes you use the shell does not expand the command containing the glob string into the resulting files on which you can appl
TAG : bash
Date : January 02 2021, 06:48 AM , By : Tom Berthon
Standard-in parse errors with bc command
Standard-in parse errors with bc command
I wish did fix the issue. not sure why you do so many shell operations when you have the full power of awk.find the max of column 4 and divide by columns 2 and 3.
TAG : bash
Date : January 02 2021, 06:48 AM , By : Nick Pegg
Using AWK to merge unique rows based on column one
Using AWK to merge unique rows based on column one
around this issue I am trying to write an AWK script to summarize data on a large text file. The order of the resulting data is important so i can't use sort. , With awk:
TAG : bash
Date : January 02 2021, 06:48 AM , By : Bo.
Bash Login Script Stalls
Bash Login Script Stalls
will help you --login is for interactive shells. Your script isn't interactive so --login shouldn't be there.If you want to load your .bash_profile you can source it:
TAG : bash
Date : January 02 2021, 06:48 AM , By : Suresh S
BASH replace a single letter only when it's alone not in a word
BASH replace a single letter only when it's alone not in a word
should help you out I do not want to replace just any letters with words. I only want to replace letters that are stand alone with exact case sensitive matches. , Use \b in the regular expression to match a word boundary.
TAG : bash
Date : January 02 2021, 06:48 AM , By : doctorbigtime
Compare 4 files line by line to see if they match or don't match
Compare 4 files line by line to see if they match or don't match
it should still fix some issue I'm trying to compare 4 text files for counts in each line: , One way to process files by lines in parallel
TAG : bash
Date : January 02 2021, 06:48 AM , By : user183345
Add character to file name if duplicate when moving with bash
Add character to file name if duplicate when moving with bash
wish help you to fix your issue Use a loop that checks if the destination filename exists, and increments a counter if it does. Replace the mv line with this:
TAG : bash
Date : January 02 2021, 06:48 AM , By : Topher Cyll
Use grep only on specific columns in many files?
Use grep only on specific columns in many files?
will be helpful for those in need Basically, I have one file with patterns and I want every line to be searched in all text files in a certain directory. I also only want exact matches. The many files are zipped. , It sounds like this might be what y
TAG : bash
Date : January 02 2021, 06:48 AM , By : Justin Bowers
xor conditional in bash
xor conditional in bash
will be helpful for those in need I want to see if any of two variables are set, but not both in bash.
TAG : bash
Date : January 02 2021, 06:48 AM , By : jgood
Fails to create azure container right after storage account was created
Fails to create azure container right after storage account was created
this will help Creation of a storage account is an asynchronous process. When you execute az storage account create to create a storage account, request is sent to Azure and you get an accepted response back (if everything went well).The whole proces
TAG : bash
Date : January 02 2021, 06:48 AM , By : Genipro
bash: arithmetic expressions inside of variables
bash: arithmetic expressions inside of variables
seems to work fine This is rather a mathematical problem than an issue with your bash code. Look at the formula for $restr_prev:
TAG : bash
Date : January 02 2021, 06:48 AM , By : user122937
jq command throws error "cannot iterate over string" when
jq command throws error "cannot iterate over string" when
around this issue This code is broken long before the 3rd line. If there isn't an outer array or object, you can't use .[]. If your data type is an object and not a list, using map() on it throws away data (specifically, it discards the keys, leaving
TAG : bash
Date : January 02 2021, 06:48 AM , By : user107021
In Bash, should I use declare instead of local and export?
In Bash, should I use declare instead of local and export?
fixed the issue. Will look into that further They exists because of the history. This manual says declare was introduced in bash version 2, local was introduced earlier. People use local, export and readonly by convention and readability.When I see l
TAG : bash
Date : January 02 2021, 06:48 AM , By : perl
Grouping command substitution variables into a subshell to run in background
Grouping command substitution variables into a subshell to run in background
wish helps you First, when putting commands inside parentheses they are run in a subshell, so the variables are never assigned in the outer scope.Second, you can't set variables in the background at all:
TAG : bash
Date : January 02 2021, 06:48 AM , By : Roel
How to display number of items in a folder - Bash
How to display number of items in a folder - Bash
wish help you to fix your issue sed has an option to execute the constructed replacement with /e. We only count subdirs, looking at the first character
TAG : bash
Date : January 02 2021, 06:48 AM , By : user158193
How to create a new procedure from bash script
How to create a new procedure from bash script
Any of those help Works for me, here's a complete code sample.Note I used SQLcl not SQLPlus, but same concept.
TAG : bash
Date : January 02 2021, 06:48 AM , By : Salikh
Sed command to uppercase text between two specific strings
Sed command to uppercase text between two specific strings
hop of those help? I want to parse a file and replace the text between "::" and ":::" with the text already there, just now capitalized. , Works for me, which makes me think you may not be on Linux?
TAG : bash
Date : January 02 2021, 06:48 AM , By : johntynan
Escape double quotes in a Jenkins pipeline file's shell command
Escape double quotes in a Jenkins pipeline file's shell command
wish help you to fix your issue To expand on my comment, a quick test revealed its the case.You need to escape twice, once the quote for the shell with a slash, and once that slash with a slash for groovy itself.
TAG : bash
Date : January 02 2021, 06:48 AM , By : user171752
pgrep -f cuts commands after 4095 characters
pgrep -f cuts commands after 4095 characters
Hope this helps You don't say which pgrep you're using, but in Debian's pgrep from procps-ng, this is a hard coded limit:
TAG : bash
Date : January 02 2021, 06:48 AM , By : m0gb0y74
I want my script to echo "$1" into a file literally
I want my script to echo "$1" into a file literally
I wish did fix the issue. This is part of my script , Escape it:
TAG : bash
Date : January 02 2021, 06:48 AM , By : adbanginwar
Shell script: unexpected token ´if"
Shell script: unexpected token ´if"
With these it helps Using the ifne util and some advice from Charles Duffy, this should meet the spec:
TAG : bash
Date : January 02 2021, 06:48 AM , By : phil
scp error when defining a "PATH" variable in a bash script
scp error when defining a "PATH" variable in a bash script
This might help you It is happening because PATH is a system variable that defines directories where the programs and scripts should be looked for. You can view its value by executing echo $PATH. In your script you are setting PATH to /SomeFolder/fil
TAG : bash
Date : January 02 2021, 06:48 AM , By : user185939
Nested loop for reading two files with bash
Nested loop for reading two files with bash
This might help you Possible by using the pr command from coreutils, also possible with other commands/tools like paste and also by Shell and AWK scripts. Least effort by using the commands from coreutils as only a few parameters are required on the
TAG : bash
Date : January 02 2021, 06:48 AM , By : Funkwarrior
Find folders with a specific name and run bash commands on each location
Find folders with a specific name and run bash commands on each location
this will help You need to cd back to the parent directory at the end of your if block. You can do that with cd in/cd out or pushd/popd or by wrapping the inside of the block (between then and fi) in a subshell (parens).An example:
TAG : bash
Date : January 02 2021, 06:48 AM , By : Meg
Replication and expansion of program flags in BASH script
Replication and expansion of program flags in BASH script
help you fix your problem You can do this by using a loop to populate an array with the options:
TAG : bash
Date : January 02 2021, 06:48 AM , By : WuJanJai

shadow
Privacy Policy - Terms - Contact Us © scrbit.com