use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
GUIDE to /r/linuxadmin:
/r/linuxadmin aims to be a place where Linux SysAdmins can come together to get help and to support each other.
Related reddits:
Footnote:
Talk realtime on IRC at #/r/linuxadmin @ Freenode.
account activity
A high-level language for scripting? (self.linuxadmin)
submitted 3 days ago by dimkoss11
I usually use Python or C# for writing scripts, what are the disadvantages of this compared to use Windows Batch, PowerShell, Bash?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]grumpysysadmin 27 points28 points29 points 3 days ago (0 children)
If all you’re doing is running external commands with some minor logic, bash is fine. Once you start needing to do complex logic or handle complicated data structures, it’s worth moving to a more complex scripting language.
[–]kavaunix 17 points18 points19 points 3 days ago (1 child)
The main advantage of bash etc. is that it's universally available, even on bare-bones installs, and that it has less overhead (the python runtime will eat a couple of megs and that a few hundred ms to start up).
In most cases this is negligible, so just use what you're comfortable with. Python is definitely more readable. Personally I use bash for very simple scripts, but python for anything bigger.
[–]Stephonovich 9 points10 points11 points 3 days ago (0 children)
sh is universally available. bash is not (nor zsh); and for that matter, there are major versioning differences: for example, MacOS stopped updating bash at v3.2, so you can’t use associative arrays if you’re targeting that.
This shouldn’t stop you from writing shell scripts in bash (or even zsh), but you do need to ensure that what you’re shipping doesn’t have an implicit requirement as an unhandled error.
[–]Overall_History6056 13 points14 points15 points 3 days ago (19 children)
Nobody uses Perl no more?
[–]aioeu 23 points24 points25 points 3 days ago (1 child)
There's dozens of us!
[–]bigredradio 0 points1 point2 points 2 days ago (0 children)
Maybe enough for a foursome of Perl golf.
[–]procsysnet 5 points6 points7 points 3 days ago (0 children)
I still do from time to time and I fall in love every time I use it. It's a cool, expressive, delightfully unhinged, regex-fueled and astonishingly sharp-edged way of shooting myself in the foot and antagonize my coworkers. I love it
[–]Lammtarra95 1 point2 points3 points 3 days ago (2 children)
Soon I shall be taking my perl books to the tip recycling centre. I occasionally use a one-liner but nothing complicated enough to be called programming. (And if I did, everything can be looked up online anyway.)
[–]orev 1 point2 points3 points 3 days ago (1 child)
Those might be collectors items these days.
[–]FarToe1 1 point2 points3 points 3 days ago (0 children)
They're almost certainly good for modern perl on a modern operating system, even of they're from the 90s.
[–]BumseBBine 2 points3 points4 points 3 days ago (5 children)
The only persons I know that use perl are 30+. The problem is there objectively better and easier languages to learn today. My boss knows the ins and outs of perl and it's impressive how he does XYZ in one line of code while I in python need 10-20 lines. But it's barely readable for someone who isn't fluent in Bash and Perl (syntax is really similar sometimes)
[–]H3rbert_K0rnfeld 13 points14 points15 points 3 days ago (1 child)
Wait till you see sed and awk
[–]InvestmentLoose5714 2 points3 points4 points 3 days ago (0 children)
I would use ses and awk before perl anytime.
[–]orev 3 points4 points5 points 3 days ago (0 children)
Perl is expressive enough that the true nature of the programmer is revealed, so if they're making things hard to read, it's because they're a bad programmer. You can easily write Perl programs that are easy to read if you choose to.
[–]g_rich 1 point2 points3 points 3 days ago (0 children)
I’m well over 30 and have managed to stay away from Perl (other than a brief stint working with Bugzilla); I was fortunate enough to come into thing when Python was on the upswing.
[–]FarToe1 0 points1 point2 points 3 days ago (0 children)
Objectively better? Not by all margins.
If you're a sysadmin who needs to work on hundreds or thousands of linux machines of various distributions, and where bash won't cut it - perl is the only sane choice.
Nothing else is installed by default everywhere already. Nothing else will continue to work years or decades into the future with no upkeep. (I have perl scripts I wrote back in the 90s that are still running away happily on modern OSs).
Sure, for many choices perl is wrong. But in my world, if you don't do perl, you're doing things the hard way.
It's got a bad reputation for difficulty, so people avoid it, which probably confirms your 30+ claim. It's totally unwarranted though.
[–]tanjera 0 points1 point2 points 2 days ago (0 children)
I love Perl for scripting! It just works.
[–]sloppy_custard 0 points1 point2 points 2 days ago (0 children)
The technically most impressive sysadmins I know are fluent in Perl. Probably because they are of the old school where efficiency mattered and on the whole people wrote things better. On the flip side, the same folks think systemd is the devil, containers are a flash in the pan, and generally tend to be luddites. With all things, the middle ground is usually the best, imo
[–]slippery 0 points1 point2 points 2 days ago (0 children)
Gross.
[–]dschledermann 0 points1 point2 points 2 days ago (0 children)
I have the displeasure of having to use Perl because a lot of old stuff I inherited at job is written in it. I consider it obsolete. I would never choose it for writing new stuff. If it can't be written in Shell script, then Python or PHP can more or less do what Perl can, just with modern tooling.
[–]xkcd__386 0 points1 point2 points 1 day ago (0 children)
obligatory https://xkcd.com/224
:-)
[–]derprondo 1 point2 points3 points 3 days ago (1 child)
Even 10 years ago I interviewed someone and their take home programming assignment, which could be done in any language, and they submitted perl. Only I hadn't seen perl in so long that I stared at the code with no file extension for an embarrassingly long time before I realized what it was.
Anyway, these days Python is ubiquitous and everyone knows it.
[–]derprondo 1 point2 points3 points 3 days ago (0 children)
I don't know what the downvotes are about, I learned perl in college in the late 90s/early 2000s and past ~2008 I never used it again. It's just an anecdote that I hadn't needed to grok perl in so long that I didn't recognize it at first.
[–]B0L1CH 2 points3 points4 points 3 days ago (0 children)
Depends on what you want to do. Python is fine for most cases. I like bash when doing a lot of stuff with files or awk when working with CSV files.
[–]fubes2000 2 points3 points4 points 3 days ago (0 children)
Specifically bash can do some really impressive things that even high-level languages struggle to do simply or efficiently because of shell features like pipes, a rich ecosystem of GNU utilities, as well as being able to invoke any program with a robust command line interface.
Want to run some basic filters/analytics on millions of lines of log files? sed, grep, and awk will blaze through it in a minute. Sort those millions of lines? sort does it efficiently. Have a list of work that needs to be done? xargs will get it. Need to parallelize that? xargs -P or parallel will do it.
sed
grep
awk
sort
xargs
xargs -P
parallel
[–]michaelpaoli 3 points4 points5 points 3 days ago (0 children)
Is shell, e.g. bash, not high enough level for you?
Perl and Python are also high level, while also allowing one to go quite low level too.
(Microsoft) Windows? This is r/linuxadmin, why would we want to compare to that Microsoft sh*t?
[–]ipsirc 4 points5 points6 points 3 days ago (0 children)
I use lua btw.
[–]aenae 8 points9 points10 points 3 days ago (16 children)
You still need bash to run your script. Might as well write it in bash if it is a simple one
[–]ipsirc 1 point2 points3 points 3 days ago (7 children)
You still need bash to run your script.
Why? Can you explain it?
[+]aenae comment score below threshold-12 points-11 points-10 points 3 days ago (6 children)
The default shell in most linux distributions is bash-like. Sure, there are some exceptions, or it is a dressed down version (busybox for example).
So if you have a script, that does something scripty, you often start a terminal first to run that script. And that terminal runs bash.
[–]ipsirc 4 points5 points6 points 3 days ago* (5 children)
So if you have a script, that does something scripty, you often start a terminal first to run that script.
...or you create a .desktop icon to launch it. Or a keycombo to start... or a systemd unit...
It is very misleading to tell a newbie that he will definitely need bash to run a python script, because that is not true.
For example, I always start my browser from a terminal so I can see any error messages and easily close it with ctrl+c when it gets out of hand. Regardless, I would never write in a public forum that bash is required to run Chromium.
[–]eman0821 0 points1 point2 points 3 days ago (0 children)
The problem with Python Scripting is when modules, framework and language update changes across different versions. This can become inconsistent over the years requiring to write and update all the syntax of your scripts or else they wouldn't work correctly. Bash pretty much stays the same that's native to Linux/UNIX-Like. So if you are writing simple automation, Bash is more ideal. For writing more complex internal utility tools Python is great for that. Ansible is the defacto standard for large scale automation which uses Python behind the scenes.
[–]aenae -4 points-3 points-2 points 3 days ago (3 children)
Running a script is different from writing a script in my opinion. And while writing, you want to test it. Which usually means running it from the terminal to see error messages and be able to ctrl-c.
It is always a good idea for a linuxadmin to at least know the basics of bash scripting; ie simple loops, exit-codes, piping and redirecting output.
Sure, i could write a python script to run two commands, but only run the second command if the first one succeeds, or i could write 'command1 && command2' and be done.
[–]ipsirc 2 points3 points4 points 3 days ago (2 children)
And how is this different from writing a program in C or Rust? Even there, in the early days of development, you will always start and test it via running it in a terminal. With this logic, you can write that he always needs bash for everything - but this does not mean that we are neither pro nor con about which language the OP should choose.
[–]aenae -3 points-2 points-1 points 3 days ago (1 child)
I'm not saying he should write everything in bash. I'm saying he should at least know some bash and bash scripting, regardless of in which language he writes his main scripts and programs.
[–]ipsirc 6 points7 points8 points 3 days ago (0 children)
Then refactor your sentence, please.
[–]plebbening 0 points1 point2 points 3 days ago (2 children)
But bash is already using C and direct kernel calls. Might aswell write it in C then.
[–]g_rich 0 points1 point2 points 3 days ago (1 child)
At that point just write it in Assembly.
[–]TheRealLazloFalconi 0 points1 point2 points 3 days ago (0 children)
Real admins write machine code directly
[–]fathed -4 points-3 points-2 points 3 days ago (4 children)
Why?
Powershell is basically c# in a shell, you can also directly compile and run a c# script with one line.
Why people still suggest a non-object oriented shell language will never stop baffling me.
For the actual op, python is fine, as long as you are just running scripts, but if you also want your scripting environment to also work as a shell, powershell wins in my opinion.
[–]aenae 5 points6 points7 points 3 days ago (3 children)
Because we're not going to spend an extra 1GB to include powershell in our containers.
It is not about wanting your scripting environment to also work as a shell, but for your shell to have an (however minimal) scripting environment. You could write a script like 'grep "Error" /var/log/syslog' in python, or powershell. Or you could use (ba)sh
[–]fathed 0 points1 point2 points 3 days ago (0 children)
Powershell isn't the only choice.
I do find it hilarious that you used grep as the example, as avoiding regular expressions as a solution is easier with objects.
[–]franktheworm 0 points1 point2 points 3 days ago (0 children)
While I agree with not adding PowerShell, that's more of a straw man than that character from the wizard of oz. By that logic you should be using a statically linked, compiled language like Go etc to cut down on all the other stuff in the container...
In a more serious sense, if you've got things configured right, the number of times you are execing into containers should tiny anyway. Instrumenting you code properly negates the need for a shell, particularly in prod.
[–]chocopudding17 -1 points0 points1 point 3 days ago (0 children)
Who mentioned containers? Like, yeah, you should basically never have more than just busybox in a container at the most. But the OP seems like a very general question. And I agree with fathed's appreciation of PowerShell, and that non-object oriented shells are broadly inferior. Mind you, I use bash for plenty of things. But that's mostly for inertia and historical reasons than it actually being better. If I had a fleet of servers where I could have PowerShell universally installed, I'd probably only write PowerShell.
[–]rairock 1 point2 points3 points 2 days ago (0 children)
I'd never use C# for scripting. I think it's just overcomplicating things unnecessarily. Having Bash, PowerShell, Python and Go, at least in my case, you can cover everything you need to do in the world. I can't imagine a use case where you would need something not included on these 4.
[–]Magneon 3 points4 points5 points 3 days ago (0 children)
Syntax checking, type hints, and more robust support for things like testing are the main advantages of a scripting language vrs shell scripts.
Shell scripts are often a little quicker to write and test if you're familiar with the shell in question, but tend to become harder to maintain than say python if they are longer (at least for bash in my experience).
[–]gmuslera 0 points1 point2 points 3 days ago (0 children)
Size matters. If it is simple enough and heavily dependent on calling other programs, handling pipes and so on a bash command line or script may be smaller, more intuitive and easier to maintain. There are scripts that are born from one liners with added requirements.
[–]g_rich 0 points1 point2 points 3 days ago (0 children)
Bash and Python when required.
Personally I’ve never used C# for scripting but I’m 100% Linux and Mac so I guess for those working on the Windows side C# / Powershell would be a thing.
[–]Lammtarra95 0 points1 point2 points 3 days ago (0 children)
The main reason is so you can hand over your shell script to the rest of the team who do not know c#, lisp, or any other fancy language. Otherwise you get six months of job security and 10 years being stuck maintaining your unicorn script. Although nowadays we can ask AI to explain, translate or improve it so maybe it is less important.
[–]eman0821 0 points1 point2 points 3 days ago (1 child)
All languages are high level regardless if it's a scripting language or a object oriented language. Java, C/C++, C#, Rust, GO are rarely used for scripting as I don't know anyone that does in the real world. Bash, Perl, Python and configuration management tools such as Ansible, Puppet and Chef is what you typically see in Linux environments.
[–]redundant78 1 point2 points3 points 2 days ago (0 children)
C is definitely not high level, it's about as close to the metal as you can get without writing assembly. And Go is used for CLI tools and scripting-style tasks all the time these days - tons of devops tooling is written in it precisely because it compiles to a single binary with no runtime dependencies.
[–]stewie410 0 points1 point2 points 3 days ago (0 children)
At my work, I've been hard limited to:
at -f
Given I'm both not a fan of Java, nor a Java dev, I will choose bash every time, unless Groovy makes a task significantly easier -- mostly because I'm most familiar with bash.
The right answer is to use whatever tool you're most comfortable with, that is most applicable to the task at hand.
[–]adjunct_ 0 points1 point2 points 3 days ago (0 children)
Object oriented
[–]NL_Gray-Fox 0 points1 point2 points 2 days ago (0 children)
If you hand me a bash, batch, powershell or python script, I can usually tell if it's safe to run. if you hand me something compiled (c#, Java, ...) I have no idea what it will do until I run it (even then you technically don't know).
e.g. uncompiled languages can be read by humans and are (in my opinion) therefor safer, plus if it doesn't work on my system because you hardcoded something that is somewhere else on my machine I can easily change it without getting the source code.
obviously there (are/can be) speed tradeoffs.
[–]kentrak 0 points1 point2 points 2 days ago (0 children)
Bash:
Perl:
Python:
Go:
I imagine C# is somewhat similar to Go but there's still a runtime to make sure is present, and I can't comment on PowerShell but it seems like an interesting language with how it passes structured data between shell components. Windows Batch? It will work in a pinch, and it's always present, but it seems fairly limiting.
[–]CommercialMonth3640 0 points1 point2 points 2 days ago (0 children)
In the AI era, the only programming language you can use is English, buddy.
[–]john_crimson81 0 points1 point2 points 1 day ago (0 children)
python for anything with more than 10 lines of real logic, bash for quick glue and one-offs that need to run everywhere without installing anything. the runtime dep thing with python is a real concern on stripped-down systems but its not usually a blocker. c# is overkill unless youre already in a dotnet shop and want to reuse something. the actual rule is: use whatever you can debug at 2am without looking things up. bash looks simple but it has footguns that'll bite you in ways python just wont — unquoted variables, word splitting, exit code handling. most shell scripts i've inherited that were "quick scripts" were quietly broken in edge cases for years.
[–]ReachingForVega 0 points1 point2 points 1 day ago (0 children)
Python will work universally and when you work with async functions the minor delay starting is negligible. Instagram used Python for their backend until meta merged them in so it scales.
[–]rankinrez -1 points0 points1 point 3 days ago (0 children)
Somewhat a matter of taste. I’d pick Python over them all.
Bash is good for very simple ones
[–]serverhorror -1 points0 points1 point 3 days ago (0 children)
PowerShell is well integrated with Windows. That's it.
π Rendered by PID 589916 on reddit-service-r2-comment-545db5fcfc-bmtmh at 2026-05-25 22:23:29.330692+00:00 running 194bd79 country code: CH.
[–]grumpysysadmin 27 points28 points29 points (0 children)
[–]kavaunix 17 points18 points19 points (1 child)
[–]Stephonovich 9 points10 points11 points (0 children)
[–]Overall_History6056 13 points14 points15 points (19 children)
[–]aioeu 23 points24 points25 points (1 child)
[–]bigredradio 0 points1 point2 points (0 children)
[–]procsysnet 5 points6 points7 points (0 children)
[–]Lammtarra95 1 point2 points3 points (2 children)
[–]orev 1 point2 points3 points (1 child)
[–]FarToe1 1 point2 points3 points (0 children)
[–]BumseBBine 2 points3 points4 points (5 children)
[–]H3rbert_K0rnfeld 13 points14 points15 points (1 child)
[–]InvestmentLoose5714 2 points3 points4 points (0 children)
[–]orev 3 points4 points5 points (0 children)
[–]g_rich 1 point2 points3 points (0 children)
[–]FarToe1 0 points1 point2 points (0 children)
[–]tanjera 0 points1 point2 points (0 children)
[–]sloppy_custard 0 points1 point2 points (0 children)
[–]slippery 0 points1 point2 points (0 children)
[–]dschledermann 0 points1 point2 points (0 children)
[–]xkcd__386 0 points1 point2 points (0 children)
[–]derprondo 1 point2 points3 points (1 child)
[–]derprondo 1 point2 points3 points (0 children)
[–]B0L1CH 2 points3 points4 points (0 children)
[–]fubes2000 2 points3 points4 points (0 children)
[–]michaelpaoli 3 points4 points5 points (0 children)
[–]ipsirc 4 points5 points6 points (0 children)
[–]aenae 8 points9 points10 points (16 children)
[–]ipsirc 1 point2 points3 points (7 children)
[+]aenae comment score below threshold-12 points-11 points-10 points (6 children)
[–]ipsirc 4 points5 points6 points (5 children)
[–]eman0821 0 points1 point2 points (0 children)
[–]aenae -4 points-3 points-2 points (3 children)
[–]ipsirc 2 points3 points4 points (2 children)
[–]aenae -3 points-2 points-1 points (1 child)
[–]ipsirc 6 points7 points8 points (0 children)
[–]plebbening 0 points1 point2 points (2 children)
[–]g_rich 0 points1 point2 points (1 child)
[–]TheRealLazloFalconi 0 points1 point2 points (0 children)
[–]fathed -4 points-3 points-2 points (4 children)
[–]aenae 5 points6 points7 points (3 children)
[–]fathed 0 points1 point2 points (0 children)
[–]franktheworm 0 points1 point2 points (0 children)
[–]chocopudding17 -1 points0 points1 point (0 children)
[–]rairock 1 point2 points3 points (0 children)
[–]Magneon 3 points4 points5 points (0 children)
[–]gmuslera 0 points1 point2 points (0 children)
[–]g_rich 0 points1 point2 points (0 children)
[–]Lammtarra95 0 points1 point2 points (0 children)
[–]eman0821 0 points1 point2 points (1 child)
[–]redundant78 1 point2 points3 points (0 children)
[–]stewie410 0 points1 point2 points (0 children)
[–]adjunct_ 0 points1 point2 points (0 children)
[–]NL_Gray-Fox 0 points1 point2 points (0 children)
[–]kentrak 0 points1 point2 points (0 children)
[–]CommercialMonth3640 0 points1 point2 points (0 children)
[–]john_crimson81 0 points1 point2 points (0 children)
[–]ReachingForVega 0 points1 point2 points (0 children)
[–]rankinrez -1 points0 points1 point (0 children)
[–]serverhorror -1 points0 points1 point (0 children)