r/bash • • Jan 06 '24

Bash used for ?

I am a Data Science students and ended up liking linux and stuff and started learning bash, I am enjoying this power of computers, but I do not understand where can I use it besides keeping it just for my resumes? what are the real life usages of bash ? does it integrates with Data Science ??

0 Upvotes

20 comments sorted by

13

u/[deleted] Jan 06 '24

Frankly for a data scientist Python would be a lot more useful however Bash or at least some basic knowledge of it would help you in your day to day. Say you have to organise hundreds of files or automate a download of data from somewhere - Bash is your best bet. Sure you can do it in other languages but Bash is very quick to write and handy.

As they say, each task has the appropriate tool for it. Bash is good for quick mockups, automation of tasks, general Linux management, file management and so on. Python, C, C++, Scala, Java and so on are great for other programming tasks and each is different than the others. If you want to be a great developer then don’t be a prisoner of a programming language and explore more efficient ways of doing your job. If something is slow in Bash, write it in C if it’s complicated in C try Python and if you don’t have any other choice use Java (joke).

7

u/[deleted] Jan 06 '24

this is the best reply I have ever got on my question irrespective of the platform or real life. totally loved it . keep up the good work human . cleared all my doubts.

4

u/grymoire Jan 06 '24

Unix has hundreds/thousands of tools available. Sort, count, search, collate, filter, transform, calculate, edit, combine, visualize, etc. And each one has been perfected to run fast, efficient and flexible. You can spend a year mastering just one of these tools. The shell is your interface to these tools - allowing you to combine them in any way imaginable. The goal is to quickly combine these tools to get your algorithm working as quickly as possible. Get the algorithm working first using the shell, and then, if necessary, consider creating a program that implements your algorithm, in the programming language you choose. But in most cases, you won't need to write a program, because the script written in bash is fast enough.

1

u/[deleted] Jan 06 '24

thank you for your comment, it hepled me get clarity

3

u/grymoire Jan 06 '24

It's difficult to comprehend how much effort has gone into these tools. The "sort" program, for example, has been improved for 60 years.

8

u/nekokattt Jan 06 '24

bash is for scripting interactions with other programs via the commandline. You probably would use something like Python for DS, but you might invoke python via a shell script if you have more complex requirements.

Additionally if you use a terminal anywhere, then bash is the most commonly used terminal on linux systems usually. Your terminal shell would be a bash interactive session.

4

u/tiben_ Jan 06 '24

are you talking about the Bash "Programming" language or more generally using a command line terminal ?

1

u/rileyrgham Jan 06 '24

Why not search here or ask Google? There's a lot of info if you can search for 2s:

https://www.reddit.com/r/bash/comments/wrb25x/i_want_real_world_examples_of_what_do_you/

1

u/[deleted] Jan 06 '24

thanks for your help, the link was very insightfull for me

1

u/omgu8mynewt Jan 06 '24

I use python to write algorithms to do the "data science" part e.g. file of columns of numbers, find the average, do some maths.

I use bash to control the algorithm e.g. use bash to write a loop, put twenty seperate files of numbers through the same python algorithm and copy and paste the individual results into a new file but labelled with whatever the input file was. File handling stuff.

1

u/[deleted] Jan 06 '24

Greatest reply I got on this, cleared all my doubts . Thanks for your comment.

2

u/Velascu Jan 06 '24

Almost everything you do in the OS can be automated with bash, you have to dig a little bit but with the right apps, yeah. Don't know much about data science but basically if you have any task that uses other apps/commands and can be automated or improved you can use bash for it, I just made 3 simple scripts but yeah, from installing an OS from scratch to opening an app with really specific settings to... I mean it's like asking what can you program with C, the answer is virtually anything.

2

u/tthatfreak Jan 06 '24

I live in a locked down environment and bare min experience with python, perl, and sql. No importing of the latest greatest libraries for me. If I can't figure it out with pure bash then I move up the chain in unfamiliarity.

1

u/power10010 Jan 06 '24

Text processing tools using pipes and loops.

1

u/yorevs Jan 06 '24

Bash and Python are keys for DS. You can leaen a lot here https://github.com/yorevs/homesetup

1

u/Entire_Finding_4601 Jan 07 '24

Sometimes you’ll really understand the usefulness of a technology - as a language for example - when you needed to use, in this case, as a data scientist, probably you wont need bash. But for example, create a script in a server level, bash is more performative.

1

u/DaveR007 not bashful Jan 07 '24

99% of my scripts are written in bash because it's what I know best. Though I do occasionally write scripts in python or php.

I even have a bash script that's 1800 lines. https://github.com/007revad/Synology_HDD_db It started off as 200 lines and just grew from there. If I was starting today and new it would get so large I'd use a different language.

1

u/Mount_Gamer Jan 07 '24

The only thing I use bash for in data science, is a little script for following the logs with colour highlighting.

We use python a lot for data science, I'm not aware of Linux tools that would easily manage what we have to do in python.

3

u/[deleted] Jan 06 '24

[removed] — view removed comment

1

u/ryapric Jan 06 '24

This is what I was going to share as well -- it's an answer to the question in-context, and a great book besides!