Using Python to Interact with the Operating System Week 6 Solution

Share on facebook
Share on twitter
Share on linkedin
Share on telegram
Share on whatsapp
Editing Files Using Substrings

Using Python to Interact with the Operating System WEEK 6 Qwiklabs Assessment Coursera  by Google. Welcome to Using Python to Interact with the Operating System. You’re joining thousands of learners currently enrolled in the course. This course is a part of Google IT Automation with Python Professional Certificate. Qwiklabs Assessment : “Editing Files Using Substrings”

I’m excited to have you on my channel and look forward to your contributions to the learning community. By the end of this course:

  1. you’ll be able to manipulate files and processes on your computer’s operating system. You’ll also have learned about regular expressions a very powerful tool for processing text files
  2. you’ll get practice using the Linux command line on a virtual machine.

And, this might feel like a stretch right now, but you’ll also write a program that processes a bunch of errors in an actual log file and then generates a summary file. That’s a super useful skill for IT Specialists to know.

-:Skills you will learn:-

  •  Setting up your Development Environment
  • Regular Expression (REGEX) 
  • Testing in Python 
  • Automating System Administration Tasks with Python
  • Bash Scripting

~Course Link:

Qwiklabs Assessment : “Editing Files Using Substrings


> oldFiles.txt
files=$(grep " jane " ../data/list.txt | cut -d' ' -f3)
for f in $files; do	
  if [ -e $HOME$f ]; then
    echo $HOME$f >> oldFiles.txt;

					#!/usr/bin/env python3
import sys
import subprocess

f = open(sys.argv[1], "r")
for line in f.readlines():
  old_name = line.strip()
  new_name = old_name.replace("jane", "jdoe")["mv", old_name, new_name])

Leave a Reply

Your email address will not be published. Required fields are marked *