I want to check if I do have enough space before executing my script. I thought about The space I want to check via Any suggestions? Answer Bringing it all together (set -e and cd omitted for brevity; Bash-specific syntax – not POSIX-compliant): df “$HOME” outputs stats about disk usage for the $HOME directory’s mount point, and awk ‘NR==2 {
Tag: shell
Read line by line and print matches line by line
I am new to shell scripting, it would be great if I can get some help with the question below. I want to read a text file line by line, and print all matched patterns in that line to a line in a new text file. For example: The intended output is as follows: I tried the following code: which
How to use grep in shell with -e option set
In bash -e option stops executing after an error and grep commands returns a non-zero status in case it does not find for the pattern it is looking for. I want to use grep inside an if statement, something like If i use $? to get the statement of last command, then the execution stops after last command as grep
Linux shell script – String trimming for dash
I am attempting to get the mac address from my Raspberry Pi take the last 6 characters of the mac to use as the hostname alongside a fixed string. here is what I’v managed to get working from other sources so far, but I am now totally stuck trying to trim the string down. the shell being used by the
Replacing string with variable with Groovy and SED command
I am trying to replace an entire description string contained in an XML file. I would like to replace that string with a variable. I am using a SED command within a Groovy script. I have the following code. I am expecting the string “foo” to replace the description text but it doesn’t. Instead the following line causes the XML
Shell script to automate the installation of cpan modules
I am writing a shell script to automate the installation of cpan (Comprehensive Perl Archive Network) modules. The first command is being executed and it enters into the cpan shell, but the later commands are not detected. I think the later commands are not being executed as it is a different shell. Any leads on this is appreciated. Thanks. Answer
Execute program with different parameters and storing results in txt file
I am trying to execute a program (let’s say myApp) in the ubuntu shell. Normally myApp is called like this: myApp /path/to/file1 /path/tofile2 the output is a matrix which will be printed on the standard output. What i want to do is to execute myApp for all files in a directory and save the output in a txt file. The
Zip Junk Paths Option Not Working
I have a bit of an odd one that I can’t seem to figure out. Here’s the setup. I am downloading a bunch of files given to a script via array. The files are not necessarily in the same folder, so I don’t think just using cd to change directory and then add the files I want is going to
Shell script works in bash but not on ‘adb shell’
Below shell script works perfectly fine in bash shell. But produces an error in android shell. May be it has got to do something with the shell that android is using. But how can I resolve it? If not a perfect solution, an hack would also do for me. Shell-script : O/p In android shell, O/p on bash shell(Linux): Answer
How to store value from grep output in variable
I am working on one bash script, in which I have to use the regular expression to match string and then store the output in a variable to reuse it. here is my script, I tried this many ways, but I am getting error : ./check.sh: MET-3-get-issue-id-from-branch-name: not found if I run individual grep command then yes, it is working