Linux2019. 9. 23. 06:57

-S로 스크린에 이름을 주고

-r -X 옵션으로 명령을 준다.

screen -S "mylittlescreen" -d -m
screen -r "mylittlescreen" -X stuff $'ls\n'

 

[링크 : https://stackoverflow.com/questions/7049252/how-to-create-a-screen-executing-given-command]

'Linux' 카테고리의 다른 글

서비스 등록 오류  (0) 2019.10.10
grep -o 매칭되는 영역만 출력하기  (0) 2019.09.25
screen 스크롤하기  (0) 2019.09.23
csv에서는 awk 보단 cut  (0) 2019.09.05
awk csv  (0) 2019.09.05
Posted by 구차니
Linux2019. 9. 23. 06:56

우오오 이런 좋은 기능이?

ctrl-a-esc

pgup/pgdn

esc

 

[링크 : https://medium.com/@erwinousy/screen-command-사용법-linux-mac-62bf5dd23110

'Linux' 카테고리의 다른 글

grep -o 매칭되는 영역만 출력하기  (0) 2019.09.25
screen 명령어와 함께 실행하기  (0) 2019.09.23
csv에서는 awk 보단 cut  (0) 2019.09.05
awk csv  (0) 2019.09.05
awk 변수 지정  (0) 2019.09.02
Posted by 구차니
Linux2019. 9. 5. 13:34

소리 절로나오는 상황 -_-

 

cut -d'|' -f2- infile > outfile2 && mv outfile2 file

[링크 : https://stackoverflow.com/questions/16448153/awk-how-to-delete-first-column-with-field-separator]

 

여러개 필드를 날릴려면 -f2,4 이런식으로 리스트로 적어주면 된다.

       -f, --fields=LIST
              select only these fields;  also print any line that contains no delimiter character, unless the -s option is specified

'Linux' 카테고리의 다른 글

screen 명령어와 함께 실행하기  (0) 2019.09.23
screen 스크롤하기  (0) 2019.09.23
awk csv  (0) 2019.09.05
awk 변수 지정  (0) 2019.09.02
awk 치환(삭제)  (0) 2019.09.02
Posted by 구차니
Linux2019. 9. 5. 12:59

awk로 csv를 처리하려면.. 구분자를 , 로 하고 손을 봐야 하는데

영 매끄럽진 않네..

 

[링크 : https://www.joeldare.com/wiki/using_awk_on_csv_files]

'Linux' 카테고리의 다른 글

screen 스크롤하기  (0) 2019.09.23
csv에서는 awk 보단 cut  (0) 2019.09.05
awk 변수 지정  (0) 2019.09.02
awk 치환(삭제)  (0) 2019.09.02
tail과 cat 합치기  (0) 2019.09.02
Posted by 구차니
Linux/Ubuntu2019. 9. 4. 15:18

설정이 꼬였나.. 기존에는 바로 된거 같은데 안되네?

 

$ sudo vim /etc/apache2/apache2.conf

Include /etc/phpmyadmin/apache.conf

$ sudo service apache2 restart

[링크 : https://tistory.woobi.org/52]

'Linux > Ubuntu' 카테고리의 다른 글

우분투 화상 키보드 끄기  (0) 2019.12.21
mx linux - xfce + debian  (0) 2019.10.14
ubuntu 18.04 wayland와 ubuntu session  (0) 2019.08.28
ubuntu virtual desktop  (0) 2019.08.28
ubuntu 18.04 fsck 예약(?)  (0) 2019.08.27
Posted by 구차니
Linux2019. 9. 2. 19:06

특정필드를 날릴려면 미리 다른데 저장을 하고 =""으로 지정하면 되겠네?

 

$ awk '/Aaron/{ first_name=$2 ; second_name=$3 ; print first_name, second_name ; }' names.txt

[랑크 : https://www.tecmint.com/learn-awk-variables-numeric-expressions-and-assignment-operators/]

'Linux' 카테고리의 다른 글

csv에서는 awk 보단 cut  (0) 2019.09.05
awk csv  (0) 2019.09.05
awk 치환(삭제)  (0) 2019.09.02
tail과 cat 합치기  (0) 2019.09.02
awk 구분자 탭으로 인식시키기  (0) 2019.09.02
Posted by 구차니
Linux2019. 9. 2. 19:05

항상 그렇지만...

삭제는 ""으로 치환하는거고 그 함수로 sub와 gsub를 지원하는 듯

 

sub

cat my_list.txt | awk -F '\t' -v OFS='\t' '{ sub("-",".",$3); print }'

[링크 : http://bahndal.egloos.com/565881]

 

gsub

awk -F\, '{gsub(/[ \t]+$/, "", $2); print $2 ":"}'

[링크 : https://stackoverflow.com/questions/9985528/how-can-i-trim-white-space-from-a-variable-in-awk]

 

sub는 처음 매칭되는 것만 치환, gsub는 전역 치환인듯

sub(r, s [, t])

Just like gsub(), but only the first matching substring is replaced.

gsub(r, s [, t])

For each substring matching the regular expression r in the string t, substitute the string s, and return the number of substitutions. If t is not supplied, use $0. An & in the replacement text is replaced with the text that was actually matched. Use \& to get a literal &. (This must be typed as "\\&"; see GAWK: Effective AWK Programming for a fuller discussion of the rules for &'s and backslashes in the replacement text of sub(), gsub(), and gensub().)

[링크 : https://linux.die.net/man/1/awk]

'Linux' 카테고리의 다른 글

awk csv  (0) 2019.09.05
awk 변수 지정  (0) 2019.09.02
tail과 cat 합치기  (0) 2019.09.02
awk 구분자 탭으로 인식시키기  (0) 2019.09.02
awk 특정 열 제외하기  (0) 2019.09.02
Posted by 구차니
Linux2019. 9. 2. 17:51

명령행으로 묶은 다음 그걸 전체로 리다이렉션 하면 되는 구나..

 

{ tail --lines=+7 text1; cat text2; } > out_put 

[링크 : https://stackoverflow.com/questions/20499969/combining-cat-and-tail]

'Linux' 카테고리의 다른 글

awk 변수 지정  (0) 2019.09.02
awk 치환(삭제)  (0) 2019.09.02
awk 구분자 탭으로 인식시키기  (0) 2019.09.02
awk 특정 열 제외하기  (0) 2019.09.02
linux 수동 trim  (0) 2019.08.16
Posted by 구차니
Linux2019. 9. 2. 15:30

-F '\t' 

[링크 : https://kldp.org/node/120883]

 

-F fs
--field-separator fs
Use fs for the input field separator (the value of the FS predefined variable).

[링크 : https://linux.die.net/man/1/awk]

 

+

출력은 탭으로 안되는데(기본값이 스페이스)

OFS

The output field separator, a space by default.

 

여러번 시도해보니.. awk'{}' OFS='\t'만 먹는다. 환경변수로 인식을 하는 듯?

awk '{split($5,a,"-"); print $1,$2,$3,a[1]}' OFS='\t' file.bed > test.bed

[링크 : https://www.unix.com/shell-programming-and-scripting/264368-awk-output-seperated-tab.html]

 

+

$ cat filename | awk -F '\t' '{$2="";print $0;}' OFS='\t' | sed 's/<.*//'

두번째 값을 날리고, 끝에 탭이 하나씩 남아서 따라오는걸 없애는 법 (두번째가 마지막 column이라고 가정)

[링크 : https://askubuntu.com/questions/232606/stdout-string-manipulate-delete-all-after-a-word-per-line]

 

+

끝이 스페이스로 끝날때 날리기

sed -i 's/[[:space:]]*$//' <name-of-file.ldif>

[링크 : https://www.theurbanpenguin.com/remove-trailing-spaces-using-sed/]

'Linux' 카테고리의 다른 글

awk 치환(삭제)  (0) 2019.09.02
tail과 cat 합치기  (0) 2019.09.02
awk 특정 열 제외하기  (0) 2019.09.02
linux 수동 trim  (0) 2019.08.16
jq - json in linux command line  (0) 2019.08.16
Posted by 구차니
Linux2019. 9. 2. 13:03

아래는 3번과 5번에 대해서 열을 날리는 예제

 

$ cat temp.txt | awk '{$3=$5=""; print $0}'

C1 C2  C4  C6 C7 C8 C9 C10

[링크 : https://ondemand.tistory.com/238]

 

+

단, 구분자를 제외하고 날리기 때문에 하나의 빈 구분자가 추가되는 식으로 출력되니 주의

'Linux' 카테고리의 다른 글

tail과 cat 합치기  (0) 2019.09.02
awk 구분자 탭으로 인식시키기  (0) 2019.09.02
linux 수동 trim  (0) 2019.08.16
jq - json in linux command line  (0) 2019.08.16
awk NR, NF  (0) 2019.08.12
Posted by 구차니