다음 쉘 스크립트가 주어지면 새 행을 삽입하기 위해 출력을 재 배열하는 방법은 무엇입니까?쉘 스크립트의 출력을 재 배열하는 방법
#!/bin/bash
echo -e $1 ` date `
시도해 보았지만 아무 소용이 없습니다.
내가 입력하면 내 말은 : ./script.sh "
LS를 나는 다음과 같은 출력을 얻을 "
-la :
total 4732
drwxr-xr-x 4 root root 4096 2013-01-09 15:32 .
drwx------ 28 root root 4096 2013-01-09 15:32 ..
-rw-r--r-- 1 root root 484063 2013-01-06 05:22 Blackhat-europe-09-Damele-SQLInjection-whitepaper.pdf
-rwxrwxrwx 1 root root 3787587 2013-01-06 05:10 FoxitReader-1.1.0.tar.bz2
-r-------- 1 root root 127693 2013-01-03 22:55 HackYeah-SQL-Injection.pdf
drwxr-xr-x 2 root root 4096 2013-01-05 21:47 Inst_DVWA
-rw-r--r-- 1 root root 3223 2012-12-22 00:47 nmap-O
-rw-r--r-- 1 root root 284 2013-01-06 07:31 payload_dvwa.txt
-rwxrwxrwx 1 root root 30 2013-01-09 11:18 script (copy).sh
-rwxrwxrwx 1 root root 33 2013-01-09 15:32 script.sh
-rw-r--r-- 1 root root 395493 2013-01-06 05:03 SQLmap_README.pdf
-rwxrwxrwx 1 root root 705 2013-01-07 15:22 start_dvwa.sh
-rw-r--r-- 1 root root 834 2013-01-06 07:31 Unsaved Document 1.txt
drwxr-xr-x 2 root root 4096 2012-12-19 18:47 ZAP_certificate
고마워 :
total 4732 drwxr-xr-x 4 root root 4096 2013-01-09 15:32 . drwx------ 28 root root 4096 2013-01-09 15:32 .. -rw-r--r-- 1 root root 484063 2013-01-06 05:22 Blackhat-europe-09-Damele-SQLInjection-whitepaper.pdf -rwxrwxrwx 1 root root 3787587 2013-01-06 05:10 FoxitReader-1.1.0.tar.bz2 -r-------- 1 root root 127693 2013-01-03 22:55 HackYeah-SQL-Injection.pdf drwxr-xr-x 2 root root 4096 2013-01-05 21:47 Inst_DVWA -rw-r--r-- 1 root root 3223 2012-12-22 00:47 nmap-O -rw-r--r-- 1 root root 284 2013-01-06 07:31 payload_dvwa.txt -rwxrwxrwx 1 root root 30 2013-01-09 11:18 script (copy).sh -rwxrwxrwx 1 root root 33 2013-01-09 15:32 script.sh -rw-r--r-- 1 root root 395493 2013-01-06 05:03 SQLmap_README.pdf -rwxrwxrwx 1 root root 705 2013-01-07 15:22 start_dvwa.sh -rw-r--r-- 1 root root 834 2013-01-06 07:31 Unsaved Document 1.txt drwxr-xr-x 2 root root 4096 2012-12-19 18:47 ZAP_certificate Wed Jan 9 15:32:55 CET 2013
내가이 유사한 출력을 좀하고 싶습니다를
여기서 샘플 출력의'\'date \ "의 출력은 무엇입니까? 'bash' 스크립트가 당신의 주장 인'ls -la'에서 수행 할 작업은 무엇입니까? 행운을 빕니다. – shellter
스크립트가 실제로 그렇게 보이면,'./script.sh "ls -la"의 출력은'ls -la Wed Jan 9 09:52:22 EST 2013'이 될 것입니다. 나는 그것이 당신이 원하는 것이라고 생각하지 않지만 귀하의 질문에서 확신하기가 어렵습니다. (a) 실제 스크립트, (b) 지금 생성하는 출력, (c) 출력하고자하는 출력을 보여주십시오. 출력의 줄 수를 줄입니다. 너는 그렇게 많은 것을 필요로하지 않는다. – larsks
귀하의 시도는 공통적 인 초보자 반 패턴 : 쓸모없는 Backticks 사용을 반복합니다. http://partmaps.org/era/unix/award.html#backticks를 참조하십시오. – tripleee