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
Mac OS X Directory Structure Outline how to organize files and directories. Describe preferences for file...
Mac OS X Directory Structure Outline how to organize files and directories. Describe preferences for file names and how the concepts of a hierarchical directory structure could improve existing method of storage. If useing an alternative method, justify its use and benefits over and above basic approaches.
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?
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 ---). Write a small report (~250 words) how might the file be compromised...
Visual Basic Make a directory and copy some files from desktop to the created directory
Visual Basic Make a directory and copy some files from desktop to the created directory
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT