0% found this document useful (0 votes)
43 views3 pages

Ses 4

The document discusses several Linux commands and concepts including: 1) wc to count lines, words, and bytes in a file. The pipe character | is used to merge commands. 2) pushd and popd manipulate the directory stack in a LIFO manner, allowing navigation to recently used directories. 3) The $PATH variable contains directories where command line executables are located. It can be updated to add custom script locations. 4) PS1 allows customizing the command prompt using escape codes for user, date, path and more.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views3 pages

Ses 4

The document discusses several Linux commands and concepts including: 1) wc to count lines, words, and bytes in a file. The pipe character | is used to merge commands. 2) pushd and popd manipulate the directory stack in a LIFO manner, allowing navigation to recently used directories. 3) The $PATH variable contains directories where command line executables are located. It can be updated to add custom script locations. 4) PS1 allows customizing the command prompt using escape codes for user, date, path and more.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

ses_4:-

o wc:-
word count
Syntax: wc filename.extension

number of lines
number of words
bytes

o pipe [|]:-

used to merge two or more commands

example:-

find . -name "*.v" | wc

o pushd and popd

push directory_path into stack


pop directory_path from the stack

LIFO process[statck]

example:-

$ pushd .
/cygdrive/d /cygdrive/d

where;
1st word indicates the directory_path which is getting pushed into the
stack.(current <Directory path pushed>)
from 2nd word onwards it indicates the contents of the stack.

$ pushd .
/cygdrive/c /cygdrive/c /cygdrive/d

$ pushd .
/cygdrive/d/PERSONAL/NOTES/SYSTEM_VERILOG/1.APB_MEMORY/mem_tb_development
/cygdrive/d/PERSONAL/NOTES/SYSTEM_VERILOG/1.APB_MEMORY/mem_tb_development
/cygdrive/c /cygdrive/d

$ popd
/cygdrive/d/PERSONAL/NOTES/SYSTEM_VERILOG/1.APB_MEMORY/mem_tb_development
/cygdrive/c /cygdrive/d

NOTE:-
when we do pop operation "popd" the linux terminal does "cd" operation
on the poped directory_path

where;
1st word indicates the directory_path which is getting poped from the
stack(current directorypath poped).
from 2nd word onwards it indicates the contents of the stack.
$ popd
/cygdrive/c /cygdrive/d

$ popd
/cygdrive/d

$ popd
-bash: popd: directory stack empty

since we have poped all the contents of the stack the stack is empty and we
get above error

Note :Application of pushd and popd --> we can push long dir path into stack, we
can acess through popd operation

o updating the shell path:-

what is ment by shell path?


when a shell executes any command or any application, shell search for the
particular command or application name if they are registerd/updated in the shell
path.

How to know what all the paths present?


echo $PATH

$PATH is environmrnt variable


$PATH has some directories in which my shells search for exe files of
the command or application

example:-

$ echo $PATH
/usr/local/bin:
/usr/bin:
/cygdrive/c/windows/system32:
/cygdrive/c/windows:
/cygdrive/c/windows/System32/Wbem:
/cygdrive/c/windows/System32/WindowsPowerShell/v1.0:
/cygdrive/c/windows/System32/OpenSSH:
/cygdrive/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:
/cygdrive/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:
/cygdrive/c/WINDOWS/system32:
/cygdrive/c/WINDOWS:
/cygdrive/c/WINDOWS/System32/Wbem:
/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:
/cygdrive/c/WINDOWS/System32/OpenSSH:
/cygdrive/c/Users/Koushik/AppData/Local/Microsoft/WindowsApps:
/cygdrive/c/questasim64_10.7c/win64:
/cygdrive/c/intelFPGA/20.1/modelsim_ase/win32aloem:
/usr/lib/lapack

Note
:whenever any command is given, it searches the exe file of command ex ls, it
searches .exe file of ls in all directory mentioned above, if file is present it
exe that file and we will get the output

Most of .exe command are found in usr/bin path,whenever we give unknown


command it gives message that it didnot find .exe file in any of path mentioned
above
whenever we exe script file we have to exe in current directory,but industry
working enviroment we all write script file in one directory, in order to exe
scsript file from any location we need to add path to $PATH enviroment variable

bash terminal looks for above path for .exefile of command

How to add new path to $PATH


in bash terminal

PATH="$PATH:<give_the_entire_directory_path of script file>"

ex: /cygdrive/d/script_dir if this path i want to register in bash


terminal path

PATH="$PATH:</cygdrive/d/script_dir >"
___________________________________________________________________________________
________________________
o PS1
promt script 1
if you want to change how the shell interacts with user. theses change can be
done using ps1 command.

\W -> current working directory name


\w -> full path of the working directory
\d -> display the current date
\u -> user of the system
\h -> hostname of the machine
\n -> new line
\s -> current shell environmrnt
\# -> display the command number
\$ -> if UID is 0 it indicates that root is accessing the terminal so the
promt will change to "#" else it remains "$" itself
\t -> display the current time in HH:MM:SS

example:-
$ PS1="\n<user=\u@host_name=\h date=\d & time=\t curr_working_dir=\W
full_path=\w shell_env=\s >\n\#->"

o ps
o kill a process
o xargs
o sed
o awk

You might also like