But I only want to use it the least possible.
All the contrary: shell scripts are like regular expression, the more you use them, the better you understand them and the easier they make your life.
But I only want to use it the least possible.
Ok, I didn't know about it, I've never heard of Thinbasic.Offtopic on: Thinbasic is a scripting language, not compiled language like other variants of basic.
BTW, I don't say I wanted to avoid shell at all. I know it's impossible. But I only want to use it the least possible. I have problems reading and understanding shell scripts.
On Java, beside arguments on JSP and JVM, I have a feeling that it going completely replaced by PWA.
Investment on Java for newcomers!?
However, back to your issue of parsing /etc/rc.d/ldconfig, I don't understand your statement "since my distro doesn't have /usr/local ".
Apart from the use of distro, what FreeBSD doesn't have /usr/local? It's been in there for, like, forever.
Well, it depends on what you want to do.Shell is too hard for me. I'm porting a JavaScript interpreter could be run with#!/usr/bin/env js
, it's written in C, it's small and fully support the ES2020 specification. The real value of it is it's a real interpreter, doesn't compile to C and relying on C compiler to compile and run the binary. That make it could be used like python and as a real scripting solution.
I come from Java, know a bit of C. I dislike JS, too. But if having to choose between shell and JS, I prefer JS. I like a full language that could be used as itself without relying on extra small utility with awful syntax like sed, awk to done the job. Yes, I know it's against the Unix philosophy. But I don't care about philosophy anyway.
On Windows, I used Thinbasic. Is there anything like that on Unix or we forced to stick with the Unix philosophy? I guess it's python.
Yes, awk(1) is somehow a mix of the spirits of the declarative & imperative programming paradigma.You should look into awk(1) if you dislike writing if-then logic. Awk's expressiveness and power really shine when you use patterns even though they're considered "advanced" by some. Take the somewhat contrived example of counting shell usage by user, and paying special attention to root's shell:
Code:#!/usr/bin/awk -f # Set the field separator to ":". Default is whitespace BEGIN { FS=":" } # Skip comment lines /^#/ { next } # Capture root's shell $1 ~ /root/ { rootShell=$7 } # Keep shell usage counts $7 != "" { shells[$7]++ } $7 == "" { shells["No shell"]++ } # Print results END { print "Root's shell is", rootShell; for( i in shells ) { print i, shells[i]; } }
Sample run:
Code:% ./shells.awk /etc/passwd Root's shell is /bin/csh No shell 1 /usr/local/libexec/uucp/uucico 1 /bin/csh 2 /usr/sbin/nologin 33
I find writing programs as a list of conditon -> action pairs fun and compelling.
Well. Now I know the reason why people wrongly associated me with the troll. I admit I have never encountered awk nor did a quick research about it before posted this thread. It's my fault. I only encountered sed and I found people using sed like using magic. I'm afraid of it and as sed and awk usually compared together, I think awk should be on the same ship as sed: has an awful syntax. This turned out to be wrong. They are very different. From the tutorial it seemed to be familiar: https://www.tutorialspoint.com/awk/index.htm But from the code I saw people posted on many question answering sites, it still looks like magic for me. Perhaps because I didn't learn it so I don't understand what the script is doing so I found it cryptic.You say you know a bit of C, but at the same time you call awk’s syntax “awful”. Are you aware the awk is quite similar to C? In fact, awk’s main author was Brian Kernighan (who is still maintaining it!) who is also co-author of the C programming language. The letter K both in “K&R C” and “AWK” stands for Kernighan. Some people say that awk is just a scriptable version of C, with some restrictions and some enhancements (associative arrays, regular expressions). Many people underestimate the power of awk considerably, often abuse it for trivial things like cutting a column from a text file. By the way, awk is also compiled to intermediate byte code. Personally I regard awk to be positioned somewhere between the POSIX shell and Python, complexity-wise. I’ve written several scripts in pure awk (i.e. beginning with “#!/usr/bin/awk -f”).
You are right. I could use functions to find and replace simple strings but never used such advanced find and replace technology.This line suggests that you are not familiar with regular expression.
No one expects anyone to embrace languages in an instance. When I first started on unix I hated [g]awk & perl but after a while of forced usage and PRACTICE I'm quite proficient in the major script & parser languages of unix (though I rarely use perl these days). I've always like regexp & sed, though sometimes I can confuse myself with sed expressions I wrote years ago.Well. Now I know the reason why people wrongly associated me with the troll. I admit I have never encountered awk nor did a quick research about it before posted this thread. It's my fault. I only encountered sed and I found people using sed like using magic. I'm afraid of it and as sed and awk usually compared together, I think awk should be on the same ship as sed: has an awful syntax. This turned out to be wrong. They are very different. From the tutorial it seemed to be familiar: https://www.tutorialspoint.com/awk/index.htm But from the code I saw people posted on many question answering sites, it still looks like magic for me. Perhaps because I didn't learn it so I don't understand what the script is doing so I found it cryptic.
And it should be emphasized that all of those 7 items are optional. For example, if you don’ need that pattern stuff, you can write an awk script that consists only of one BEGIN clause (with all of the code inside), and nothing else.Basically, AWK is fairly easy:
- initialization (BEGIN{...})
- function definitions
- process data & collect derived metadata:
- pattern1 action1
- pattern2 action2
- ...
- finalization (END{...}): usually print out derived metadata
#!/usr/bin/awk -f
BEGIN {
print "Hello World!"
}
Regular expressions aren’t difficult to learn. I assume you already know wildcard patters that are used for filename matching (e.g.You are right. I could use functions to find and replace simple strings but never used such advanced find and replace technology.
ls -l d*
). Regular expressions work in a very similar way, the syntax is just a little different, and there are more things that you can do with them.You are right. I could use functions to find and replace simple strings but never used such advanced find and replace technology.
I guess it's coming with version 13
Kyle Evans' Development Arena
Modern GUI scripting is done e.g. by QML + JavaScript. Using a declarative approach in this realm, as well as JavaScript's asynchronous behaviour, is very natural. But it's not well suited for CLI scripts.[..] The suggestion to use TCL/TK for gui work wasn't terrible, but it is a bit esoteric.
A little bit of background on the Lua story …In some ways this is perhaps good. If someone suggests that we put Python in base, now we can turn around and say we already have Lua. Awk doesn't seem enough of a brand name.
30 years ago, Rexx was the best scripting language around; the alternatives (/bin/sh, CLIST and DCL) were much worse. Perl and Tcl were just getting started and not broadly available, Python and Ruby and Lua and all the other modern ones not invented yet. In the early 90s, I used to write 1000-line scripts in Rexx on both VM and VMS (yes, on the Digital operating system!), because the only alternatives were FORTRAN and C and PL/1.Nobody has mentioned Rexx. I used it on zOS platform. Quick Freshport scanning reveals Rexx interpreter existence.
Then now you stopped advocating for Ada but switched to OCaml? BTW, thank you
30 years ago, Rexx was the best scripting language around
I remember it from my Amiga, Arexx was quite integrated in the AmigaOSRexx was possibly my first "programming language".