Question

In: Computer Science

List all files and directories in the current directory and store in a variable called malf....

List all files and directories in the current directory and store in a variable called malf.

Count how many lines end with your firstname in the file /etc/conf

Explain this command: mv pmu*.[ab]   cces/  

Quick help in 5 min pleases with the UNIX program!
I want only the final answer

Solutions

Expert Solution

Please let me know if you need more information:-

======================================
List all files and directories :===> ls
List all files and directories including hidden files and directories ===> ls -a

Example:-

===================

ss139t@ss139t:~$ ls
As2_sbah DownVote.sh FSUTIL ipv6_verify.py 'new 8.py' q105 Q49.py Q5.sh q78 root_fil2 run_cmd.py sri srinu2 total.pl
createfile findDir.sh guess.cpp Module3 pdf_file.py Q2.sh Q4.sh q70 Q8.sh root_file shellScriptFunction.sh srinu ssr
ss139t@ss139t:~$ malf=`ls`
ss139t@ss139t:~$ echo $malf
As2_sbah createfile DownVote.sh findDir.sh FSUTIL guess.cpp ipv6_verify.py Module3 new 8.py pdf_file.py q105 Q2.sh Q49.py Q4.sh Q5.sh q70 q78 Q8.sh root_fil2 root_file run_cmd.py shellScriptFunction.sh sri srinu srinu2 ssr total.pl
ss139t@ss139t:~$
==============
Including hidden files:-

==============

ss139t@ss139t:~$ malf=`ls -a`
ss139t@ss139t:~$ echo $malf
. .. As2_sbah .bash_history .bash_logout .bashrc .cache createfile DownVote.sh findDir.sh FSUTIL .gnupg guess.cpp ipv6_verify.py .lesshst .local Module3 new 8.py pdf_file.py .profile .python_history q105 Q2.sh Q49.py Q4.sh Q5.sh q70 q78 Q8.sh root_fil2 root_file run_cmd.py .selected_editor shellScriptFunction.sh sri srinu srinu2 .ssh ssr .sudo_as_admin_successful total.pl .viminfo
ss139t@ss139t:~$

==============

Count how many lines end with your firstname in the file /etc/conf
=====
grep -w "firstname$" /etc/conf |wc -l

==

root@ss139t:/etc# cat /etc/conf
1how are you firstname
2 firstname dhshjjds
3djfjsdfhshf
4jsfskf firstname
5fdjsjfs firstname
6jfjsjnfs
7fsfs
8fsfsfsgfsg
9gsagfsgfsag firstname
root@ss139t:/etc# grep -w "firstname$" /etc/conf
1how are you firstname
4jsfskf firstname
5fdjsjfs firstname
9gsagfsgfsag firstname
root@ss139t:/etc# grep -w "firstname$" /etc/conf |wc -l
4
root@ss139t:/etc#

===

==

Explain this command: mv pmu*.[ab]   cces/  

==

mv ==> move command

you need to under here is starting with ==> pmu
and then fillowed by anything ==> * (star)
and then follow by dot must be present ==> . (dot)
and then must be with extension with letter a or b ==> [ab]
cces/ ==> this to to directory

See the below example

===

ss139t@ss139t:~/test$ ls -l
total 40
drwxrwxr-x 2 ss139t ss139t 4096 Mar 30 10:53 cces
drwxrwxr-x 2 ss139t ss139t 4096 Mar 30 10:50 pmua
drwxrwxr-x 2 ss139t ss139t 4096 Mar 30 10:50 pmub
drwxrwxr-x 2 ss139t ss139t 4096 Mar 30 10:50 pmud
-rw-rw-r-- 1 ss139t ss139t 0 Mar 30 10:53 pmujdj.a
drwxrwxr-x 2 ss139t ss139t 4096 Mar 30 10:53 pmujdj.afd
-rw-rw-r-- 1 ss139t ss139t 0 Mar 30 10:53 pmujdj.b
drwxrwxr-x 2 ss139t ss139t 4096 Mar 30 10:53 pmujdj.bfhs
drwxrwxr-x 2 ss139t ss139t 4096 Mar 30 10:51 pmujdj.hd
drwxrwxr-x 2 ss139t ss139t 4096 Mar 30 10:51 pmujdj.s
drwxrwxr-x 2 ss139t ss139t 4096 Mar 30 10:51 pmujdj.z
drwxrwxr-x 2 ss139t ss139t 4096 Mar 30 10:50 pmuz
ss139t@ss139t:~/test$ ls -l cces
total 0
ss139t@ss139t:~/test$ mv pmu*.[ab] cces/
ss139t@ss139t:~/test$ ls -l
total 40
drwxrwxr-x 2 ss139t ss139t 4096 Mar 30 10:54 cces
drwxrwxr-x 2 ss139t ss139t 4096 Mar 30 10:50 pmua
drwxrwxr-x 2 ss139t ss139t 4096 Mar 30 10:50 pmub
drwxrwxr-x 2 ss139t ss139t 4096 Mar 30 10:50 pmud
drwxrwxr-x 2 ss139t ss139t 4096 Mar 30 10:53 pmujdj.afd
drwxrwxr-x 2 ss139t ss139t 4096 Mar 30 10:53 pmujdj.bfhs
drwxrwxr-x 2 ss139t ss139t 4096 Mar 30 10:51 pmujdj.hd
drwxrwxr-x 2 ss139t ss139t 4096 Mar 30 10:51 pmujdj.s
drwxrwxr-x 2 ss139t ss139t 4096 Mar 30 10:51 pmujdj.z
drwxrwxr-x 2 ss139t ss139t 4096 Mar 30 10:50 pmuz
ss139t@ss139t:~/test$ ls -l cces
total 0
-rw-rw-r-- 1 ss139t ss139t 0 Mar 30 10:53 pmujdj.a
-rw-rw-r-- 1 ss139t ss139t 0 Mar 30 10:53 pmujdj.b
ss139t@ss139t:~/test$

==

Please let me know if you need more information.

====

Thanks


Related Solutions

Display and store a long listing of all the regular files and directories in /personal_files. Store...
Display and store a long listing of all the regular files and directories in /personal_files. Store the output in a file called mypersonalfiles. UNIX
Unix ramdom question. How do you display a list of files in your current directory, sorted...
Unix ramdom question. How do you display a list of files in your current directory, sorted by file size with the largest files at the top.
Write a bash script to find all the files ending with .c recursively for every directory...
Write a bash script to find all the files ending with .c recursively for every directory in your current working directory, then copy each one to a folder called programs, need handle duplicates by appending the number to the end of the file (ex main.c main-1.c ) compile them and generate a report report should look like: main.c compiles prog2.c failed main-2.c compiles etc.
UNIX treats file directories in the same fashion as files; that is, both are defined by...
UNIX treats file directories in the same fashion as files; that is, both are defined by the same type of data structure, called an inode. As with files, directories include a nine-bit protection string. If care is not taken, this can create access control problems. For example, consider a file with protection mode 644 (octal) contained in a directory with protection mode 730. How might the file be compromised in this case?
Unix treats file directories in the same fashion as files; that is, both is defined by...
Unix treats file directories in the same fashion as files; that is, both is defined by the same type of data structure, call an inode. As with files, directories include a non-bit protection string. If care is not taken, this can create access control problems. For example, consider a file with protection mode 644 (rw- r-- r--) contained in a directory with protection mode 730 (rwx -wx ---). How might the files be compromised in this case?
Write a program that creates a file called "data.dat" in the current directory. Prompt the user...
Write a program that creates a file called "data.dat" in the current directory. Prompt the user for five numbers, and write them, one at a time, on both the screen and into the file. Close the file, then open it again for reading only, and display the contents on the screen. Handle error conditions that may occur. Please Need this to be done in PERL. Thanks
Java Chapter 12.29 (Rename files) suppose you have a lot of files in a directory named...
Java Chapter 12.29 (Rename files) suppose you have a lot of files in a directory named Exercisei_j, where i and j are digits. Write a program that pads a 0 before j if j is a single digit. For example, a file named Exercise2_1 in a directory will be renamed to Exercise2_01. In Java, when you pass the symbol * from the command line, it refers to all files in the directory (see Supplement III.V). Use the following command to...
Java Programming: spellcheck Write code to read in a dictionary from the current directory called "dict.txt"...
Java Programming: spellcheck Write code to read in a dictionary from the current directory called "dict.txt" (you can find this in the current directory/data) Add each word to a hash map after splitting words and throwing away punctuation (see the demo). open a file called "spell.txt" to check in the current directory. Print out every word in spell.txt that is NOT in the dictionary. Example: if spell.txt contains: hello, this is a test. 2152189u5 Misspelled! cApitalized The output should be:...
Write a C++ app to read both files, store them into parallel vectors, sort the list...
Write a C++ app to read both files, store them into parallel vectors, sort the list of people in alphabetical order, display the new sorted list of names with their corresponding descriptions. Use the Bubble Sort strategy to rearrange the vector(s). File 1: Marilyn Monroe Abraham Lincoln Nelson Mandela John F. Kennedy Martin Luther King Queen Elizabeth II Winston Churchill Donald Trump Bill Gates Muhammad Ali Mahatma Gandhi Margaret Thatcher Mother Teresa Christopher Columbus Charles Darwin Elvis Presley Albert Einstein...
UNIX/LINUX SCRIPT: Create a named directory and verify that the directory is there by listing all...
UNIX/LINUX SCRIPT: Create a named directory and verify that the directory is there by listing all its contents. Write a shell script to validate password strength. Here are a few assumptions for the password string.   Length – a minimum of 8 characters. • Contain alphabets , numbers , and @ # $ % & * symbols. • Include both the small and capital case letters. give a prompt of Y or N to try another password and displays an error...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT