I just realized I haven't posted a Linux tip in quite a while, so here's one that's a bit more advanced than my other ones. CAUTION this is pretty nerdy: The [mapfile] command is a seldom used builtin BASH command that is more often used in scripts than directly in the terminal emulator itself. What it can do: It allows you to create a new array variable from standard input (stdin) with each entry terminated by a delimiter of your choosing (or newline [NUL] by default.) Did I lose you? It's OK, let's just keep going. Let's say you have a file called "names.txt" with the following three lines in it: Adam Paul Robert Let's create an array variable called "people" using each line from the names.txt file: mapfile people < names.txt Here we have created an array with three entries. Each entry is given its own number in ascending order starting from zero. So 0 is "Adam", 1 is "Paul" and 2 is "Robert". Understand? Zero is a number too. So what can we do with this? We can call any given line from the array and use it however we like. Let's simply echo the first entry from the variable to display it on stdout: # echo ${people[0]} Adam We can also display all of the entries at once by using the @ symbol rather than a specific array assignment: # echo ${people[@]} Adam Paul Robert Now, if you're an advanced BASH user you might be asking why not just use a "read loop". Sure, that would be a more portable option but creating an array in this fashion is much faster. Final thought: You don't have to use a file to create an array with mapfile. You may use anything from stdin with any delimiter you like. Use your imagination. Now tell me what this one does and you win the internet for today: mapfile -t parts < <(lsblk | grep part) #linux #nerdystuff #programming #scripting #BASHscript
Luke H.’s Post
More Relevant Posts
-
Anyone who has followed me for a while knows that I am an avid (read: staunch) Linux user. I've also been a Windows user for several decades, but I truly feel at home with Arch and Debian-based Linux systems. Those who work in IT should be intimately familiar with the three major desktop operating systems, regardless of personal preference. Sure, there are several exceptions that could be raised against this statement; obviously, the tech industry has many sides. For the most part, however, we should know Windows and Linux equally well in order to maintain the value we bring to employers. As for MacOS, just learn as much as you can stand to learn (kidding). It is important to remember that all operating systems have their use cases. Windows is best suited for user desktops and domain controllers, where Linux can do whatever you want it to do except run the latest games! 😉 MacOS, you're still pretty. #systemadministration #windows11 #linux #sysadmin #IT
To view or add a comment, sign in
-
After 20 long months of job searching, I am excited to announce that I've been hired in IT. I've been in auto parts sales and the retail space for quite a long time (just how long makes me sound older than I am 🙃 ) Throughout this endeavor countless people have donated their time and expertise to help me reach this milestone. I won't name names, but the people who have been involved in this long journey know who they are. I am eternally grateful for their help. (If you think I may be talking about you, I'm talking about you.)
To view or add a comment, sign in
-
-
Home lab projects on the resume? Yes or no? Please discuss. #homelab #it #informationtechnology #cybersecurity #infosec #linux #windows
To view or add a comment, sign in
-
-
I have become disillusioned. What is real anymore? Are the people I am connecting with even real people? Is one year of account history and 200 followers enough to believe that they're real? If not, where is that threshold? Is there really a skills gap? Or is the bulk of the need nestled within tight niches of expertise and we're only seeing the fodder that actually gets listed? The job listings seem so fake anymore. Many have accused the bulk of them as being fraudulent data harvesters, or serving only as a flag to show the competition that they're growing and doing well with no intention to actually hire. Was that thought-provoking article I just read generated by AI, and were the statements represented as facts actually based on facts? Of course if I have time to read it with the intention of believing it then I should have time to fact check it. But are authors being disingenuous by pumping generated content into their blogs even if they believe it? And do I fact check my checked facts? Who fact checks the fact checkers? Maybe if I want to work in tech I should consider working with fact checking fact check checkers. Who wants to write the code? ChatGPT? Gemini?
To view or add a comment, sign in
-
I *WANT* to work! My experience in management has shown me that individuals who are driven to succeed are consistently top performers. While looking to fill a role, I always prioritize passion over experience. I believe that, given the opportunity, I will become a valuable asset to any team. Take a chance on me, and I promise to make it count. If you know someone that is hiring for an entry-level IT role, please tag them in the comments. #IT #wanttowork #drivenbypassion #infosec #cybersecurity #opentowork
To view or add a comment, sign in
-
-
Docker is easier than you think! In less than 10 minutes you could have your own self-hosted Google Drive alternative. Give it a shot! #fileserver #docker #homenetwork #networking #virtualization #informationtechnology #it #linux
To view or add a comment, sign in
-
I generally think it isn't appropriate to mentor someone into a field that you have yet to be hired into yourself. However, I have been searching for work for a long time and I've learned a whole lot along the way. I have made a lot of mistakes that I believe were holding me back and I'd like to become a mentor for someone who needs help getting started. If you are trying to get your first job in IT and you feel like you need some direction or help getting started then please feel free to send me a DM. I work full time and am attending college classes so I only have time for one or two individuals. Requirements: 1) You must really want this. I don't want to waste my time with someone that isn't serious about IT. 2) Remember that I'm still job hunting myself, so take whatever I tell you and think critically with it. Ultimately you must do what you think is best for you. 3) If you don't know what thinking critically means, look it up before you message me. #mentorship #informationtechnology #cybersecurity #linux #infosec
To view or add a comment, sign in
-
I initially started this as a post, however when I exceeded the character limit I rolled it into this article. Let me know what you think! #linux #cybersecurity #systemadministration #sysadmin #computing #infosec
Beginner's Guide to Linux System Hardening
Luke H. on LinkedIn
To view or add a comment, sign in
-
What can you expect if you were to hire me? Detail Oriented: I must know how everything related to my job works. Even the smallest details are crucial, as they can sometimes lead to something important. Quick Learner: I am never one to be OK with not understanding a concept. If I walk away from something I need to know but do not understand, I will obsess over it until I do. Dependable: An employer that has invested in me expects a return on their investment. I take that seriously. I have always held my attendance record to a high standard. Quality: A job worth doing is a job worth doing well. I am not OK with meeting the average. If you or someone you know has a role available for someone like me, please send me a DM.
To view or add a comment, sign in
-
Linux Specialist | Linux Enthusiast
1moLove it. Keep making these please.