July 15, 2010

Linux tips and tricks (2)

Say you are on a network computer and wish to know the system specs. You can use:

cat /proc/cpuinfo
cat /proc/meminfo

Which will return you information about the CPU and memory in the system. There are more files in /proc which will give you information.

Searching for number of instances of a string in a file:

e.g. grep 'Y =' *log|wc (to search for the string 'Y =' in all files ending with log. wc gives word count)

Clearing a file. Recall the standard output operator. Now use:

cat /dev/null > test2.log


- 2 comments by 2 or more people Not publicly viewable

  1. Mike Willis

    You don’t need to cat /dev/null into a file to empty it, you can just use >
    For example:

    me@mine:/tmp> echo hello > world
    me@mine:/tmp> cat world
    hello
    me@mine:/tmp> >world
    me@mine:/tmp> cat world
    me@mine:/tmp> 

    16 Jul 2010, 12:20

  2. Thanks a lot! That does seem to work better!

    16 Jul 2010, 12:56


Add a comment

You are not allowed to comment on this entry as it has restricted commenting permissions.

July 2010

Mo Tu We Th Fr Sa Su
Jun |  Today  | Aug
         1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31   

Search this blog

Tags

Galleries

Most recent comments

  • Thanks a lot! That does seem to work better! by on this entry
  • You don't need to cat /dev/null into a file to empty it, you can just use > For example: me@mine:/tm… by Mike Willis on this entry

Blog archive

Loading…
Not signed in
Sign in

Powered by BlogBuilder
© MMXXII