6) How would you remove blank lines from a file?
grep "^$" filename > filename.new
Can also use sed and awk
7) How would you list the files in the current directory sorted by size?
ls -l | sort -k 5 -n[r]
8) How would you display the routing table?
netstat -r
9) What is a sparse file. Give a common example of it being used?
A record based file where the contents may be written to certain offsets
based on the record number and the record structures length. This could
mean that the file appears larger than it actually is , this is normally
achieved using system calls such as fseek() and fsetpos().
lastlog & coredumps are typical examples.
10) How would you find the time/date of the last reboot?
who -b
Please feel free to comment on any of this.
Unix Questions & Answers - Part 2
Unix Questions & Answers - Part 2
Last edited by wacky on Mon Aug 03, 2009 2:22 am, edited 1 time in total.
-
- Subedar
- Posts: 355
- Joined: Sat May 07, 2005 11:54 am
- Location: Lahore
- Contact:
ok waiting for.
Regards
Rana Tanveer
+923224194457
Linux Student
For Affordable Web Development http://www.affordableprogrammers.com
http://www.qualityprogrammers.com
Rana Tanveer
+923224194457
Linux Student
For Affordable Web Development http://www.affordableprogrammers.com
http://www.qualityprogrammers.com
-
- Site Admin
- Posts: 5132
- Joined: Fri May 02, 2003 10:24 am
- Location: Karachi
- Contact:
Re: Unix Questions - Part 2
Dear wacky,
Salam,
# sed '/^$/d' file > newfile
or
# grep -v '^$' file > newfile
or
# w
Best Regards.
Salam,
You can use either sed, grep for this purpose.wacky wrote:6) How would you remove blank lines from a file?
# sed '/^$/d' file > newfile
or
# grep -v '^$' file > newfile
# ls -lSwacky wrote:7) How would you list the files in the current directory sorted by size?
# route -nwacky wrote: How would you display the routing table?
Not sure about that ...wacky wrote:9) What is a sparse file. Give a common example of it being used?
# uptimewacky wrote:10) How would you find the time/date of the last reboot?
or
# w
I saw this after writing whole post so i think i should let it go.wacky wrote:Please don't post your answers here. I'll put the answers here in a couple of days' time.
Best Regards.
Farrukh Ahmed