What's in Bash / Python / Perl / Ruby / Sed / Awk for system administration, coding accessories

I know that the question is very subjective. But I can not formulate the question much better. I would appreciate some recommendations.

As a developer, I often feel how much easier it would be if I had some tools to perform a rather complicated task in a log file or in a set of source files or some data sets, etc.

It is clear that when the same type of task needs to be done repeatedly and when the speed is critical, I can think about writing it in C ++ / Java.

But in most cases, this is some kind of text processing or file search activity that I want to do only once to perform a quick check or conduct a preliminary analysis, etc. In such cases, I would be better off doing the task manually rather than writing to C ++ / Java. But I could do it in a few seconds if I knew a language like Bash / Python / Perl / Ruby / Sed / Awk.

I know that this whole question is subjective and there is no objective definite answer, but in general, what does the community of developers feel in general? What subset of these languages ​​you need to know so that I can easily perform all these tasks and improve my productivity.

Would Perl be a good choice?
This is a super set of Sed / Awk, plus it allows you to write short code. I can do with fewer lines of code. It is not readable and easy to maintain, but I never wanted these features anyway. The only thing that bothers me is the negative publicity that Perl has received recently, and has been criticized by the Ruby / Python communities. Also, I'm not sure if it can completely replace bash scripts. If not, is Perl + Bash a good combination for these tasks?

+5
source share
7 answers

I would use Perl over the bash / sed / awk combination. Why?

shell/awk/sed . sed/awk , , /, , ( ) .

+1

ruby. Perl, , . perl ruby -n, -e -p.

-e 'command'    one line of script. Several -e allowed. Omit [programfile]
-n              assume 'while gets(); ... end' loop around your script
-p              assume loop like -n but print line also like sed

, ruby ​​

seq 1 4 | ruby -ne 'BEGIN{ $product = 1 }; $product *= $_.to_i; END { puts $product }'
24

perl

seq 1 4 | perl -ne 'BEGIN{ $product = 1 }; $product *= $_; END { print $product }'
24

Python :

seq 1 4 | python -c 'import sys; print reduce(lambda x,y : int(x)*int(y),  sys.stdin.read().splitlines(True))'
24

bash/awk/sed, .

+7

Python , bash, : import os .. bash - . / bash!

+4
+3

, , bash/sh awk. Bash awk . unix , , , , awk .

1) cut
2) sed
3) wc
4) (e)grep
5) cat
6) head 
7) etc..

, . , script script.

Perl/Python - sysadmin. , sysadmin. - , , .

Ruby, , sysadmin, , Perl/Python.

+1

, , Python, .

, ++ Java, Python 4 . .

+1

bash sed, . bash , grep .

, . , (, vi), (, , , SQL, ).

, , , bash/sed, perl . ikkebr, python, , , ( ) perl; -, - , python, .

0

All Articles