All Questions
91 questions
1
vote
2
answers
5k
views
How to run the command "sudo sh /path/to/script.sh" by double clicking?
I have a question from this thread How to run a bash script by double clicking by entering the path in sudoers?. Since it was explained to me that it is unsafe to grant sudo privileges to the script....
0
votes
0
answers
36
views
How to properly format the command argument for sudo? [duplicate]
I have a command that is similar to this minimal example:
$ sh -c 'echo "1=$1"' _ foo
1=foo
$
When I want to run it through sudo, it stops working:
$ sudo -i -u user -- sh -c 'echo "1=...
0
votes
2
answers
44
views
How to add the strings in a particular line without hardcoding
I have 2 files, 1st file it has the output and another one template. I want to add ID's in the template from output without hardcode the value.
Output.txt,
abc 8392382222
def 9283923829
...
2
votes
1
answer
455
views
notify-send with stderr in notification body if there is stderr
Suppose I have a command like:
foo() {
echo a
echo b >&2
echo c
echo d >&2
}
I use the following command to process stdout in terminal but send error via notify-send
foo ...
0
votes
2
answers
87
views
What's a clean way to run a specific command C for each line L of a given file F and then move every L where C(L) ran unsuccesfully?
Say that
https://example.nosuchtld
https://example.net
https://example.org
https://example.willfail
is the content of urls.txt. I want to run <command> <url> for every URL/line of urls....
-2
votes
1
answer
678
views
grep to find an exact word match with a period in it
I have a huge .csv file in this format:
"acc","lineage"
"MT993865","B.1.509"
"MW483477","B.1.402"
"MW517757","B.1.2"
&...
0
votes
0
answers
21
views
Is opt a special name in Bash Script? [duplicate]
I was reading an answer on Unix Stack Exchange for creating a Menu in bash.
Link to which is as follows:
Arrow key/Enter menu
I'm not able to understand how opt is having content of the array.
See the ...
0
votes
2
answers
7k
views
How to accept input with spaces from command line in bash script
Currently I am having a bash script in which I accept input from the command line, but the input is with spaces and the bash script is not reading the word after the space. The script is something ...
2
votes
3
answers
613
views
Move files to directory according to the content pattern matching
I would like to move files in existing directory files containing specific content to an existing or new directory and subdirectory by writing a script called fruit in ~/bin that moves them to dir/...
0
votes
1
answer
356
views
awk prints if and else case
I wrote the following command: lsblk -nl /dev/sdd -o MOUNTPOINT | awk '{if (NR!=1 && $1) { print 1; } else { print 0; }}'
It is supposed to check if any of the paritions of the given device, ...
0
votes
1
answer
1k
views
Unable to transfer file from Linux to Windows machine with scp
Through Shell script, I've to transfer files/directories from Linux machine to Windows shared location hence tried with following command -
scp <directory-location-path-on-linux>/pom.xml "\\...
1
vote
2
answers
2k
views
How to check Windows remote path exists from Linux command?
My Jenkins pipeline runs from Linux machine and I want to check if Windows shared path like - '\\domain\parent\child\grand-child\ exists or not through shell script.
If same was to run from Windows ...
1
vote
1
answer
3k
views
How to get only memory peak usage with /usr/bin/time?
I am building a script with usr/bin/time program to monitor the RAM usage of a script and storing it in a variable so i can check if it is higher than a specified limit $mlimit, like this example ...
-1
votes
3
answers
2k
views
How to get absolute path of found file using 'find' command in Linux?
I'm checking if file present with find command like following -
find ${pwd} | grep 'Test.*zip'
This command returns output with relative path like -
./ReleaseKit/Installable/Test-5.2.0.11.zip
Is ...
0
votes
0
answers
557
views
How to store value of specific cell from console output table in a variable on Linux?
I have to get process id of process running against port 8080 hence executed command -
lsof -i :8080
It returns output like -
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 2576 ...