- 웨이모, 엠마(EMMA) 논문 공개 "멀티모달 모델을 자율 주행 영역으로 확장"
- 네이버 밴드, 미국 월간 활성 사용자 600만 돌파 "3년 만에 2배 성장"
- 칼럼 | 적절한 의도와 잘못된 주체…오픈AI '심플QA'의 한계
- Bluesky's stormy day: How its explosive growth led to inevitable outages
- I spent the weekend reading on Amazon's newest Kindle - and it's more capable than it looks
Lesser-known xargs command is a versatile time saver
First, the xarg command’s basic function is pretty simple. It echoes what you toss at it. In a sense, it’s not very different from echo, except that content needs to be redirected to it, not presented as an argument.
$ echo a b c
a b c
$ echo a b c | xargs
a b c
Obviously, nothing is gained in the example above. The pipe and the use of xargs are just making the command more complex and a bit more time-consuming. But the command does illustrate how xargs takes each string that is passed to it and repeats it.
In the example below, we just type xargs and then hit enter. Then we type some text. I typed control-d after the text and pressing the enter key. You won’t see the control-d (^d), of course, but I included it below to show where it was entered. The xargs command displays the text again. You could enter as many lines of text as you cared to and all would be repeated after the control-d.
$ xargs
Hello, World!
Goodbye for now.
^dHello, World! Goodbye for now.
In a similar fashion, if you need to have the contents of a simple file show up on a single line, basically flattening the file, xargs will comply with your wishes.
First, the file:
$ cat data
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Then the flattening of its contents with xargs: