I have never run into this scenario before so I could use a little help. I am trying to issue an if/else statement from a shell command but within perl. I’ve tried system and exec with no success. Here’s a sample of the code If I run the command if ! dpkg -l curl &> /dev/null; then apt-get …
Tag: bash
Adding to $PYTHONPATH with bash script
I wrote a bash script to add to my $PYTHONPATH. My .sh file has the following: What I want to be added to my .bashrc is: However I can only get it to add: I don’t want the actual $PYTHONPATH value to be added to my .bashrc, just the variable name. Please help! Answer Use single-quotes: The shell does no…
Bash: Read in file, edit line, output to new file
I am new to linux and new to scripting. I am working in a linux environment using bash. I need to do the following things: 1. read a txt file line by line 2. delete the first line 3. remove the middle part of each line after the first 4. copy the changes to a new txt file Each line
differentiate sudo and
I would like to make my user run as sudo and as a normal user depending on his choice.He could use sudo or normal but on not using sudo I have to disable some functionalities to get rid of errors.So how could I know that user as given me sudo permissions to execute or not? I am building my application
Color information disappears when writing a result of ‘grep –color=auto’ into a file
When I do as below with an aliased grep(grep –color=auto) it returns abcde (ab in red). but foo.txt has just abcde. I guess my terminal shows ab in red in the 1st case according to some tags by ‘grep’ but foo.txt does not contain them. Is it due to grep? Does grep judge what returning value …
find command not printing files with .wav extension as specified
I’ve tried using this command to recursively search a folder and print .wav files, showing only the file names (not the location): I’ve also tried putting .wav in double quotes like so: When I check the Wav_files.txt file there are also .xml files listed. I only intend to print the .wav files- Wha…
Bash Jq parse json string
I’ve to call a file and pass a json as parameters in this way (suppose that my file is called test.sh), from bash I need to do something like this: and the content of test.sh is the following the output of -> printf “$system_user” is but the output of -> printf “$accounts” …
Bash list datetime between two dates
How to list all datetimes in the format “+%Y-%m-%d %H:%M:%S” ? This only prints the dates, but I want the time included as well i.e. 2016-07-20 08:33:21 Answer Hope this one can help you: Output:
Bash: transform key-value lines to CSV format [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 years ago. Improve this question Editor’s note: I’ve clarified the problem definition, because I think the proble…
How Do I Fix This SED Command to Find & Replace a String
Good-day, I’m working on a Bash script for Debian Jessie and in this line; I am trying to find base_dir}/scripts and replace it with script_dir} so that my new line will read as: This is what I have tried so far; which results in this error; I am confused as to how to resolve this and would appreciate s…