How would I extract all the available classes from a Jar file and dump the output, after some simple processing, to a txt file. For example, if I run jar tf commons-math3-3.1.6.jar a subset of the output would be: I would like to convert all / to . And all $ to . Finally I would also like to remove
Tag: shell
How to exit from shell script if any of the command in SSH returns non-zero value
I have a shell script with below ssh command to perform few actions, Directory $remoteLocation/yyy is not available and it will display the error as, ./test.sh: line 6: cd: /opt/test/yyy: No such file or directory and it is proceeding to the next line. My scenario is to exit from the shell script itself if any command in ssh returns non-zero
Option -l of exec shell command
Could you please clarify on the use of -l option of exec shell command. I didn’t notice any difference when I ran exec ls | cat and exec -l ls | cat. Answer The -l option of exec adds a – at the beginning of the name of your command. For example: Note the – everywhere before diff. The point
How to change the created and last modified date of a file to present time in Linux Shell? [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question
Filtering a Block
I have multiple blocks of the below pattern I want to extract a block with Particular ID and Particular Name. The output should display For example :- I wanted to do using grep, sed, awk Thanks. Answer This sed should work for you: But you’d better use an xml parser as xmllint or xmlstarlet to parse valid xml files.
Bash script to list all processes in the foreground process group of a terminal
How can I write a bash script to print out the PIDs of all processes in the foreground process group of a given terminal (which is different from the one in which I run the script)? I know that the C function tcgetpgrp can do the job, but I am wondering if there exist any command line utilities that can
bash ls output to file when ls finds no results
i’m relative new to scripting in bash, and made the following script: At the end of the script, i don’t make a new MLSready file. When i execute the script, i expect to see the result of the latest ‘ls -l’ command in my logfile, however (because i didn’t create a new MLSready file?) the output is redirected to my
How/where to provide sudo password for Vagrant shell provisioners?
I am trying to build a Vagrant box (CentOS) that will be provisioned by an install.sh shell script. This script will do several things, the first of which, involves creating the correct directory structure under /opt so that my service can be installed there and do other things, like writing logs there, as well. So my Vagrant project (so far)
Replace very near word to a number with another word [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 6 years ago. Improve this question Replace very near string to a number with another string How to replace
Strange output in shell script
I’m encountering a very strange thing while writing a shell script. Initially I have the following script. When I ran this script, every 60 seconds, I’ll see the $DATETIME,$FIELD1 values in my log file. What is very strange, is that every 30 seconds or so, after the first minute has passed, I’ll see 20160920_120232,, meaning there was output where there