cat 으로 멀티라인을 읽어서 xargs  로 처리하고 싶은데 멀티라인이 아니라 하나만 처리될경우.... (사실 전체가 하나로 넘어가는거겠지만)

이때 하나하나 라인마다 실행하고 싶으면

from https://unix.stackexchange.com/questions/7558/execute-a-command-once-per-line-of-piped-input

The accepted answer has the right idea, but the key is to pass xargs the -n1 switch, which means "Execute the command once per line of output:"

cat file... | xargs -n1 command

Or, for a single input file you can avoid the pipe from cat entirely and just go with:

<file xargs -n1 command
  • 1
    Also of interest is the ability of xargs to not run if stdin is empty:  --no-run-if-empty  -r : If the standard input does not contain any nonblanks, do not run the command. Normally, the command is run once even if there is no input. This option is a GNU extension. – Ronan Jouchet Oct 24 '15 at 19:58 
  • 4
    How dyou access the line inside command ? – B T Apr 14 '16 at 1:21
  • This is the correct use of xargs. Without -n1, it only works on commands that treat lists of parameters as multiple invocations which not all do. – masterxilo Mar 15 at 9:43
  • printf "foo bar\nbaz bat" | xargs -n1 echo whee splits by words and not by lines – Gismo Ranas Oct 24 at 8:32

와!! 그래 -n1  이다 ..  아주 좋은 명령이네;

Comment +0

설정 > data formats > type 을 number(숫자) 로 해두고 use grouping 체크를 해제하면 된다.

Comment +0

from https://acrobatusers.com/tutorials/javascript_console

Using the Console to run code

JavaScript code can be executed directly from the Console Window. This ability is a huge time saver since it provides a fast and easy way to test out code before it's placed into a scripting location where it will be more difficult to debug.

Let's try out some simple examples. Enter the following line of code into the Console Window. 

3 + 4 

To run the code, make sure the cursor is on the same line as the text. You can place it anywhere on the line as long as nothing is selected. Either of the two following actions will cause Acrobat to run the code. 

  • Press Ctrl+Enter on Windows, or Command+Enter on Macintosh. 
  • If your keyboard has a number pad, you can use the Enter key on the number pad without pressing the Control (Command on Mac) key. Macintosh's have the additional issue of keyboard configuration mentioned earlier.

Acrobat displays the result of the execution on the next available line, also shown in Figure 4.

위의 url 을 따라가도되고..

1. cmd+j 를 눌러서 자바스크립트 디버거를 띄운다. 이때 자바스크립트 기능을 켤래? 라고 물어오는데 켠다. 혹은 메뉴에가서 직접 켠다

2. 테스트를 위해 1+2 입력후 cmd+enter 하면 3이 나온다.

3. 자..이제 본격적으로 revse .. 뒤집자. 

for (i=this.numPages-1;i>=0;i--)


입력후 cmd+enter 로 실행. 하면 뒤집힌다. 끝 

Comment +0