Posts

How to empty the files in UNIX?

Image
There are two ways to empty the file are set of files at a time(using loops) in unix 1). Using the symbol  " > "   i.e. /local/home# > /bharath/file1  now the file1 became empty. Example: [root@www ~]# cat file1 this is my first file in linux linux is rhel6.4 linux kernel dvpd by linus torvalds [root@www ~]# ls -l file1 -rw-r--r--. 1 root root 84 Apr 22 05:19 file1 You have new mail in /var/spool/mail/root [root@www ~]# >file1 [root@www ~]# ls -l file1 -rw-r--r--. 1 root root 0 Apr 22 05:19 file1 [root@www ~]# cat file1 [root@www ~]# 2). using /dev/null we can empty the file as below. [root@www ~]# ls -l file2 -rw-r--r--. 1 root root 159 Apr 22 05:22 file2 [root@www ~]# cat file2 this is linux opensorce OS linux is very compatiblw Linux kernel is develped by linus torvalds liux os has 3 IPC's namely semaphore,sharedmemory,message queue [root@www ~]# cat /dev/null > file2 [root@www ~]# ls -l file2 -rw-r--r--. 1 ...

The value and usage of Dollar $ in UNIX/LINUX and shell scripting

Image
Scenario1: Dollar($) can be used to get the value of user-defined variable and also system-defined variables like HOME,LOGNAME,PATH,PS1,IFS,SHELL etc.. [root@localhost ~]# x=18 [root@localhost ~]# echo $ x 18 [root@localhost ~]# echo $ PATH /usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin [root@localhost ~]# Scenario2:$PS1 Some times when you login to a particular user(other than root -> since root always has prompt #)of  UNIX/LINUX server the prompt appears as Dollar($) it’s because of the primary Prompt String(PS1) has been set a like below  .If you  want you can change it as your customized prompt. [root@localhost ~]# echo $PS1 [\u@\h \W]\ $ [root@localhost ~]# su - bharath [bharath@localhost ~] $ Scenario3->$0: $0 gives the name of the shell or shell script. "$0" gives the running script name with absolute path. If you want only the  script name you have to use  bas...

HANUMAN CHALISA (హనుమాన్ చాలీసా)

Image
ఆపదా మపహర్తారమ్ దాతారం సర్వ సంపదాం                                                            లోకాభిరామం శ్రీ రామం భూయో భూయో నమామ్యహం !!!!!!!!! హనుమన్ అంజనా సూనుహు వాయుపుత్రో మహాబలః .....  రామేశ్చః  ఫల్గుణ శతః పింగాక్షో అమిత విక్రమః ! ఉదదిక్రమన శ్సైవా సీతా శోక వినాశకః ... లక్ష్మణ ప్రాణ దాతాచ దశ గ్రీవశ్య దర్పః ...ఆఆఆఆఆఆఆ ! ద్వాదశీ ఐతాని నామాని కపీంద్రస్య మహాత్మనః .. స్వాపకాలే పతే నిత్యమ్ యాత్రా కాలే విశేషతః ! దశ్య మృత్యు భయం నాస్తి ..... సర్వత్ర విజయీ భవేచ .....  ఆఆఆఆఆఆఆ !!!!!! .  .  .  శ్రీ హనుమాను గురుదేవు చరణములు .. ఇహ పర సాధక శరణములు ....  బుద్ధి హీనతను కలిగిన తనువులు ... బుద్బుదములనే తెలుపు సత్యములు ... !!!!!  .  .  శ్రీ హనుమాను గురుదేవు చరణములు .. ఇహ పర సాధక శరణములు ....  బుద్ధి హీనతను కలిగిన తనువులు ... బుద్బుదములనే తెల...

What is Control_M Character and Different ways to remove it

Image
1.What is Control-M Character: A control-M(^M) is a carriage return(CR or \r). Ø   In DOS/Windows text files , all lines are typically ends with a CR(Carriage Return)  and LF(Line Feed) i.e. the combination of \r  and \n Ø   Where as In Unix/LINUX text files , all lines are typically ends with single LF(Line Feed) i.e. with \n. So if we send the files from Windows to Unix/LINUX using ftp,pscp there should be files in lines ends with CR and LF and If we execute those files in Unix/LINUX you will get error since Unix/LINUX doesn’t understands the Carriage Return(CR’S or \r) characters These  Carriage Returns(CR'S à \r ) are called Control M (^M) characters. 2.File Transfer from windows to LINUX: 1).I have created a file named sample_win.txt in my windows 7 machine and transferred using pscp to Linux machine as below, C:\VMWARE\bk>pscp C:\Users\Bharath\Desktop\win\ sample_win.txt root@192.168.183.139:/root/machintosh ro...