'Tips/LINUX'에 해당되는 글 36건

  1. 2008.05.15 Some Useful Commands
  2. 2008.05.15 CUT Simple example
  3. 2008.05.01 How to find files changed within 24 hours
  4. 2008.05.01 SMB mount
  5. 2008.05.01 /dev/fb0 to image
  6. 2008.02.16 [TIP] MOUNTING USB MEMORY in LINUX
Tips/LINUX2008. 5. 15. 17:41

FOLLOWING IS FROM Bash-Prog-Intro-HOWTO-11.html
------------------------------------------------------------------------------------
This section was re-written by Kees (see thank to...)

Some of these command's almost contain complete programming languages. From those commands only the basics will be explained. For a more detailed description, have a closer look at the man pages of each command.

sed (stream editor)

Sed is a non-interactive editor. Instead of altering a file by moving the cursor on the screen, you use a script of editing instructions to sed, plus the name of the file to edit. You can also describe sed as a filter. Let's have a look at some examples:

        $sed 's/to_be_replaced/replaced/g' /tmp/dummy
        

Sed replaces the string 'to_be_replaced' with the string 'replaced' and reads from the /tmp/dummy file. The result will be sent to stdout (normally the console) but you can also add '> capture' to the end of the line above so that sed sends the output to the file 'capture'.

        $sed 12, 18d /tmp/dummy
        

Sed shows all lines except lines 12 to 18. The original file is not altered by this command.

awk (manipulation of datafiles, text retrieval and processing)

Many implementations of the AWK programming language exist (most known interpreters are GNU's gawk and 'new awk' mawk.) The principle is simple: AWK scans for a pattern, and for every matching pattern a action will be performed.

Again, I've created a dummy file containing the following lines:

"test123

test

tteesstt"

        $awk '/test/ {print}' /tmp/dummy
        

test123

test

The pattern AWK looks for is 'test' and the action it performs when it found a line in the file /tmp/dummy with the string 'test' is 'print'.

        $awk '/test/ {i=i+1} END {print i}' /tmp/dummy
        

3

When you're searching for many patterns, you should replace the text between the quotes with '-f file.awk' so you can put all patterns and actions in 'file.awk'.

grep (print lines matching a search pattern)

We've already seen quite a few grep commands in the previous chapters, that display the lines matching a pattern. But grep can do more.

        $grep "look for this" /var/log/messages -c
        

12

The string "look for this" has been found 12 times in the file /var/log/messages.

[ok, this example was a fake, the /var/log/messages was tweaked :-)]

wc (counts lines, words and bytes)

In the following example, we see that the output is not what we expected. The dummy file, as used in this example, contains the following text: "bash introduction howto test file"

        $wc --words --lines --bytes /tmp/dummy
        

2 5 34 /tmp/dummy

Wc doesn't care about the parameter order. Wc always prints them in a standard order, which is, as you can see: .

sort (sort lines of text files)

This time the dummy file contains the following text:

"b

c

a"

        $sort /tmp/dummy
        

This is what the output looks like:

a

b

c

Commands shouldn't be that easy :-) bc (a calculator programming language)

Bc is accepting calculations from command line (input from file. not from redirector or pipe), but also from a user interface. The following demonstration shows some of the commands. Note that

I start bc using the -q parameter to avoid a welcome message.

   $bc -q
        

1 == 5

0

0.05 == 0.05

1

5 != 5

0

2 ^ 8

256

sqrt(9)

3

while (i != 9) {

i = i + 1;

print i

}

123456789

quit

tput (initialize a terminal or query terminfo database)

A little demonstration of tput's capabilities:

        $tput cup 10 4
        

The prompt appears at (y10,x4).

        $tput reset
        

Clears screen and prompt appears at (y1,x1). Note that (y0,x0) is the upper left corner.

        $tput cols
        
80

Shows the number of characters possible in x direction.

It it higly recommended to be familiarized with these programs (at least). There are tons of little programs that will let you do real magic on the command line.

Posted by young.h.rhie
Tips/LINUX2008. 5. 15. 11:41
$cat test.txt
8 11 15
$ cut -f1 -d' ' test.txt
8
Posted by young.h.rhie
Tips/LINUX2008. 5. 1. 12:54
$ find ./ -mtime 0

해설
-mtime은 modified time을 의미하고 그 다음에 나오는 숫자를 n이라고 하면 n*24 시간 전을 의미한다. 그러니까 n은 날짜로 생각하면 된다.

추가로 예를 들면,

-mtime -5 지난 5일전부터 지금까지 수정된 파일
-mtime 5 오일전에 수정된 파일
-mtime +5 지난 5일 이전에 수정된 파일

과 같이 +, -를 활용할 수 있다.
Posted by young.h.rhie
Tips/LINUX2008. 5. 1. 12:52

mount -t cifs //192.168.1.10/share /mnt/smb -o username=Administrator,password=xxxx

Posted by young.h.rhie
Tips/LINUX2008. 5. 1. 11:52

1. Read data from /dev/fb0
  [15bit]  raw15toraw24 < /dev/fb0 > raw24.tmp
  [16bit]  raw16toraw24 < /dev/fb0 > raw24.tmp
  [24bit]  cat /dev/fb0 > raw24.tmp
  [32bit]  raw32toraw24 < /dev/fb0 > raw24.tmp

2. Raw Data to ppm
rawtoppm 800 600 raw24.tmp > ppm24.tmp

3. ppm to png
 pnmtopng <ppm24.tmp >screenshot.png

Posted by young.h.rhie
Tips/LINUX2008. 2. 16. 00:42


#mount -t vfat -o iocharset=utf8 /dev/sda1 /mnt
Posted by young.h.rhie