Shell
Shell Script – Rename Files’ Suffixes One By One
The following shell script is used to rename the files suffix at the current directory. After giving it the executable permission, we can use it like Code snippet: Result:
The following shell script is used to rename the files suffix at the current directory. After giving it the executable permission, we can use it like Code snippet: Result:
I want to write a bash script to listen for CPU resource usage. If there is a long time for high CPU consumption, the script will kill the relevant process. I refer to the qustion https://unix.stackexchange.com/questions/66786/bash-script-that-automatically-kills-processes-when-cpu-memory-usage-gets-too-hi on the stackexchange.
Inspiration: the famous fork bomb in the Linux world.Fork bomb::(){:|:&};. It’s like a crazy binary tree that consumes the resources of the system constantly. Fork bomb has an impact size of . The script here can’t do that terrible damage. Keep the size , use curl to access the target Read more…
Here is a bash script helps you to rename files *.c.gz to new files *.c. Code snippet: #! /bin/bash cmd1=$(ls |grep c.gz) cmd2=$(ls |grep c.gz |sed ‘s/\.gz//g’) array1=() len1=0 for i in $cmd1; do array1[$len1]=$i len1=$(expr $len1 + 1) done array2=() len2=0 for i in $cmd2; do array2[$len2]=$i len2=$(expr $len2 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…
I always get the error code 127 from my web application. I didn’t figure it out because it’s successful to run the program in the shell environment. The core logic in the calling function is like the following code snippet.
We often use TCP and UDP connections in Internet communication. TCP (Transmission Control Protocol) is connection-oriented, it tracks all data sent. By contrast, UDP (User Datagram Protocol) doesn’t care about datagrams it sent, all information is no sequencing. In other words, UDP is unreliable. Both socket technologies can be used Read more…
Preparation Knowledge SSH is a very useful tool which supports to use all kinds of commands to control remote computer for developers. Before interacting with the server, users are required to login with a username and password to be certified. But it’s inconvenient for us to input password every time Read more…