Shell
Shell Script – Add strings to the beginning of files
Here is a shell script to find all txt files and add string “my_begin” to the beginning of files.You can change the string for your target.
Here is a shell script to find all txt files and add string “my_begin” to the beginning of files.You can change the string for your target.
Here are some folders which contain json files.These json files have a version value, just look like the following image. We will increase this number by 10 for every json file in current folders recursively.Install command line tool jq to modify json file easily.Ubuntu: sudo apt-get install jqWindows: just download exe on the Read more…
Let’s write a shell script example to make note about how to find the first occurrence position and the last occurrence position of substring in string. Output:
In the following example, we will create a function to compute number’s factorial result.Let’s echo in the function to support fetch return value outside. Output:
If you have a few zip files in a folder, and the zip file had compressed some child zips, the following shell script can help you to extract them. The compressed information in our example look like: Shell script: #! /usr/bin/bash # find zips in current path files=() find . Read more…
rm is a basic command line tool on Linux OS. It is efficient but can be dangerous if we use incorrectly because it can delete all files and can’t undo. The post shows a way to change its default behavior. Create Shell Script myrm Write a shell script and make Read more…
I find a old C plus plus project wrote all log to a local file, it didn’t truncate the local file but just append strings. Here is a simple file, I used the string “finished” to split it to different parts. this is a story about history haha finished the Read more…
Let’s do a simple experiment, to check the Internet connection between the user’s computer and a set of IPs by a shell script. The basic command tool is Ping which sends packets to network hosts. It will receive a network response in a short time if the Internet connection is Read more…
Development environment: VTK-8.1.1 macOS 10.14.4 Qt 5.11.2 Clang 8.1.0 package for vtk program use otool command tool to find all depent library files for executable. otool -L exe Then we can redirect all output logs into a local file and make it as a shell script file. Rewrite it and Read more…