Question

How to use command line argument in python to write a program implement linux command 'find'?

How to use command line argument in python to write a program implement linux command 'find'?

Homework Answers

Answer #1

### we can use argument parser in python for Commnad line Argument

For Example :

-------------

import argparse

my_parser = argparse.ArgumentParser(fromfile_prefix_chars='@')

my_parser.add_argument('a',
                       help='a first argument')

my_parser.add_argument('b',
                       help='a second argument')

my_parser.add_argument('c',
                       help='a third argument')

my_parser.add_argument('d',
                       help='a fourth argument')

my_parser.add_argument('e',
                       help='a fifth argument')

my_parser.add_argument('-v',
                       '--verbose',
                       action='store_true',
                       help='an optional argument')

# Execute parse_args()
args = my_parser.parse_args()

print('If you read this line it means that you have provided '
      'all the parameters')
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a C program that creates (or spawns) a child process to execute the Unix's command...
Write a C program that creates (or spawns) a child process to execute the Unix's command (echo) with a string as the command-line argument; while the program itself (the parent process) will execute another Unix command less with a filename as the command-line argument. If you aren't sure how the echo and less commands are meant to behave, experiment with them by running them directly from the command line first.
Write a program in C that takes a file name as the argument on the command...
Write a program in C that takes a file name as the argument on the command line, and, if the file is a symbolic link, prints out the contents of that link (i.e. the file name that the link points to). If it is not a symbolic link, the program should print an error int main ( int argc , char * argv [] ) { // Check if the user gave an argument , otherwise print " ERROR :...
should be in Linux, please Write a shell program named A1L21 Your program should set permissions...
should be in Linux, please Write a shell program named A1L21 Your program should set permissions for a file whose name is given as an argument to your program. The permissions must be changed using a SINGLE chmod command, and must be set to EXACTLY rw for owner and group and x for others. Your program should NOT show any error messages on the screen, even if the given file does not exist, etc.
linux Using dpkg or apt, what would be the full command you would use to find...
linux Using dpkg or apt, what would be the full command you would use to find out if the python package was installed? This is tricky because Python’s actual package name is python3. $ If it is installed, what version is installed according to the dpkg or apt output? If it wasn’t installed, can you install it? What command would you use to do this? $ 2. Using dpkg, what would be the full command you would use to determine...
Write and show how you would compile and run a C program that uses command line...
Write and show how you would compile and run a C program that uses command line arguments in the terminal.
Linux File Systems: Please write down a pseudo code that implements shell command “find . -name...
Linux File Systems: Please write down a pseudo code that implements shell command “find . -name myfile -print”.
5. Write a bash command that will display the name of every file on the Linux...
5. Write a bash command that will display the name of every file on the Linux system whose file contaent contains the string "doug.jones". The command must run in the background, must redirect standard error to /dev/null, and must redirect standard output to ~/out. 6. Write a bash command that will kill all of the even-numbered processes associated with your userid, and no other processes. 7. Write a bash command that will start the program /home/courses/140u-doug.jones/zombie_maker as a background process,...
Unix / Linux 11. Globbing (filename substitution): Provide an argument to the ls command that will...
Unix / Linux 11. Globbing (filename substitution): Provide an argument to the ls command that will result in a globbing expression that meets the following description: Filenames that have a length of 5 characters. 12. Globbing (filename substitution): Provide an argument to the ls command that will result in a globbing expression that meets the following description: Filenames that begin with an alpha and end with a digit. 13. Globbing (filename substitution): Provide an argument to the ls command that...
How would I go about answering these questions In linux. Please provide the correct linux command...
How would I go about answering these questions In linux. Please provide the correct linux command needed to answer these 4 questions 5. Display total words of each file under your root directory and subdirectories. 6. Change permission of every filename ends “.py” to — write read execute, group - read execute, other - execute 7. Find every line which contains “hello” from your file system, display both file name, line number. 8. Combine files with name “p3.py”, “p31.py”, “p32.py”,...
How do you find files whose names contain embedded spaces? What would the Linux command(s) be?...
How do you find files whose names contain embedded spaces? What would the Linux command(s) be? How do you delete them? What would the Linux command(s) be?
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT