본문 바로가기

분류 전체보기61

텍스트 파일에서 해당 패턴의 N번째 occurrence까지 뽑아내는 명령어 예시) input.txt 파일에서 100번째 빈 문장 까지를 잘라내는 명령어> head -`grep -n -P '^$' input.txt | head -100 | cut -d : -f 1 | tail -n 1` input.txt > output.txt 설명)grep -n -P '^$' input.txt: input.txt 파일에서 empty string을 regex (^$) 를 이용해서 라인 넘버와 함께 (-n) 출력. head -100: 100번째 줄까지 (-100) 만 출력. cut -d : -f 1: 라인을 콜론으로 잘라내어 (-d :) 첫 필드만 뽑아냄 (-f 1). tail -n 1: 마지막 한줄 (-n 1) 만 뽑아냄. 2014. 7. 28.
긴 인터넷 주소를 짧게 줄여서. 긴 인터넷 주소를 줄여주는 서비스로 가장 유명한 서비스는 tinyurl.com이나 goo.gl 등의 외국 서비스인데 한국에서도 비슷한 서비스가 다음의 한 팀에서 나왔다. durl.kr / durl.me (durl는 한글로 '여기'. 외우기 쉽네. ㅎㅎ) 장점은 링크를 만들면 미리보기가 지원된다는 점이다. 외국 서비스들은 줄여진 링크가 어느 사이트로 연결되는지 불안해서 잘 안열어보게 되는데.이건 미리보기 서비스를 지원해서 사용자가 확인후에 그 사이트로 진행할 수 있는 점이 참 매력적이다. 실험삼아 내 블로그 주소 (hajadc.tistory.com)도 한번 줄여봤다.마우스 커서를 링크 옆에 아이콘에 가져가면 프리뷰와 뷰 카운트를 보여준다http://durl.kr/6oc6md 미리보기 한번 맛 보시길 :) 2014. 3. 11.
[Java] 지수 함수 구현 /** * Created with IntelliJ IDEA. * User: hajadc.tistory.com * Date: 8/25/13 * To change this template use File | Settings | File Templates. */ public class Power { private static final double BASE = 3.1; private static final int POWER = 8; private static int count = 0; public static void main(String[] args) { count = 0; System.out.println("Operation: " + BASE + "^" + POWER); System.out.println(.. 2013. 8. 26.
[Java] '/', '%' 연산자 쓰지 않고 나눗셈 구현하기 /** * Created with IntelliJ IDEA. * User: hajadc.tistory.com * Date: 8/25/13 * To change this template use File | Settings | File Templates. */ public class Division { private static final int DIVISOR = 2; private static final int DIVIDEND = 1024; private static int count = 0; public static void main(String[] args) { // 1024 / 2 count = 0; System.out.println("Operation: " + DIVIDEND + " / " + DI.. 2013. 8. 26.