Skip to content
Advertisement

Tag: shell

Extract class names from JAR with special formatting

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

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

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 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

Advertisement