What are the pitfalls of Shell script programming in linux
This article is about what the Shell scripting pitfalls are in linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Shell scripts are great, and you can write useful things very easily. It's even like this stupid command:
# name it with the word containing Go: $grep-I ^ go / usr/share/dict/* | cut-d:-f2 | sort-R | head-n1goldfish
If you use other programming languages, it takes more brainpower to implement it in multiple lines of code, such as Ruby:
Puts (Dir ['/ usr/share/dict/*-english'] .map do | f | File.open (f) .readlines .select {| l | l [0.. 1] .downcase = = 'go'} end.flatten.sample.chomp)
The Ruby version of the code is not that long, nor is it complex. But the shell version is so simple that I don't even have to actually test it to make sure it's correct. For the Ruby version, I'm not sure it won't go wrong. I have to test it. And it's twice as long and looks more complicated.
That's why people use the Shell script, which is simple but practical. Here is another example:
Curl https://nl.wikipedia.org/wiki/Lijst_van_Nederlandse_gemeenten | grep'^