Skip to content

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

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

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&#821…