Embracing Linux in Windows 11: A Fun Journey with Regex and WSL

Introduction: Your Adventure Begins!

Welcome to an exciting fusion of Linux and Windows 11! Imagine you’re a digital explorer, ready to delve into the rich world of Linux, right from the comfort of your familiar Windows environment. This guide isn’t just about commands and codes; it’s about embarking on an adventure in data manipulation using the Windows Subsystem for Linux (WSL) and the art of regular expressions (regex). You’ll learn to harness the power of Linux’s command line, turning complex data tasks into simple, fun exercises.

Step 1: Unveiling the Linux Command Line in WSL

Imagine opening a treasure chest – that’s what it’s like when you first open WSL. Let’s peek inside:

  • The ls Command: Like shining a flashlight in a dark room, ls reveals the files lying in your current directory.
ls # Reveals your treasures (files)

Accessing Windows Treasures from Linux:

  • Think of /mnt/c as a secret passage to your Windows files.
cd /mnt/c # Enter the secret passage
ls # Behold the treasures (Windows files)

Step 2: The Essentials – Your Command Line Toolkit

Every explorer needs a toolkit. Here’s yours for navigating this new world:

Listing Files (ls):

  • Discover what’s around you with different lenses (-l for details, -a for hidden items).
ls
ls -l
ls -a

Changing Paths (cd):

  • Navigate through the realms of directories like an expert.
cd Documents # Journey to Documents
cd .. # Step back

Identifying Your Location (pwd):

Never get lost! Use pwd to know exactly where you are.

pwd # Where am I?

Step 3: Fetching Precious Data from Distant Lands

Let’s embark on a quest to retrieve data from the mystical JSONPlaceholder API:

Using curl and wget:

  • Send out your data-fetching eagles using these commands.
wget -O posts.json https://jsonplaceholder.typicode.com/posts

Step 4: Mastering the Art of Regex – Your Secret Decoder

Regular expressions are like secret decoders for text. Crack codes and find patterns with ease!

Simple Regex Usage:

  • Extract only the letters from a given string – like finding diamonds in the sand.
echo "Hello World 123" | grep -Eo '[A-Za-z]+' # Unearthing letters

Step 5: Filtering Data with Grep

Turn your data into a goldmine by extracting only the nuggets you need:

Using grep:

  • Find lines in your data that are like hidden messages in a bottle.
grep ‘”title”:’ posts.json # Discovering hidden titles

Step 6: Storing Your Loot – Redirecting Output

Now, let’s store these treasures in a new chest (a text file):

Saving Your Finds:

  • Keep the precious lines in a secure text file.
grep ‘”title”:’ posts.json > titles.txt # Locking away the titles
Step 7: Exploring and Altering Your Textual Treasures
Viewing and Editing:
Peek into your chest of texts and modify them as you wish.
cat titles.txt # Gaze upon your collection
nano titles.txt # Carve your marks (edit)
Bonus Knowledge: Extra Tools for Your Linux Adventure
Enhance your command line journey with these additional tools and knowledge:
Understanding Your Linux Environment:
Get to know your surroundings better with lsb_release -a.
lsb_release -a # Discover your Linux landscape

Author

Above guidelines on Getting started with Linux is contributed by our Premium kit community member Umang Gulati

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top

Discover more from

Subscribe now to keep reading and get access to the full archive.

Continue reading