Unix Commands
Unix Commands
Re: in a growing log file how will you see the 1st 99 lines?
Ans):-head -99 <file name> - display 1 st 99 lines
tail -99 <file name> - display last 99 lines
Re: write grep commands to select the lines that have exactly two characters
Ans):- grep "^..$" filename
Re: what is the difference between SED and GREP ? Which one is more better and why?
Ans):- Both serves the purpose of "pattern matching" in files.SED has
more features compared to simple GREP. Ex: like replacement of
existing string with new string. Deleting the lines in a file etc
Re: How to display a file name which has zero bytes in size.
Ans)- we can find using find command.
find / -size 0
This will print all files under / which has 0 size.
Re: Assume the following files are in the working directory prompt> ls -l tasks -rw-r--r-- 1 alex student
1423 Feb 21 14:01 tasks What command can Alex use to give everyone permission to write to the file?
What will the ls -l command display if he does so? Answer
#2
chmod 666 tasks will give all users (owner, group and
others) the read-write permission.
r = 4
w = 2
x = 1
therefore rw = 4+2 =6
ls -l : lists a large amount of information of all non-
hidden files and directories in the current working
directory. eg (permissions, owners, size, and when last
modified.