어떤 Linux / Unix 명령이 구식이며 강력한 대안이 있습니까? [닫은]
오늘 나는 당신이 tail -f 처럼 행동 을 덜 할 수 있음을 발견했습니다 .
less filename 을 입력 한 다음 Shift-F를 눌러 팔로우 모드를 시작하십시오.
꼬리와 마찬가지로 스크롤, 검색 및 검색 적중 강조 표시와 같이 덜 추가 된 모든 기능이 있습니다.
나는 수년 동안 꼬리가있는 로그 파일을보고있었습니다.
이것은 단지 나를 숙고하게 만들었습니다. 구식이며 강력한 대안이있는 다른 명령이 있습니까?
게시물 당 하나의 명령 인 행복을 공유하십시오.
나는 프로그래머를위한 grep의 대안 인 내 자루를 지적하고 싶다.
나는 (나를 포함하여) 사람들이 오랫동안 찾기와 xargs를 가진 자갈과 별명과 쉘 스크립트로 살았던 것에 놀랐습니다.
시도 htop - top
스테로이드에.
시도 multitail - tail
스테로이드에.
가장 명백한 :
더 적은 것입니다.
정확하게 대체하는 것은 아니지만 moreutils 는 작은 Unixy 도구 모음으로, 기본적으로 * nix 도구 상자의 구멍을 메우기위한 것입니다.
게시물 당 하나의 명령 만 원했기 때문에 스폰지 출력을 선택해야하므로 파이프의 출력을 입력으로 사용되는 파일 중 하나에 저장할 수 있습니다. IOW를 사용하면 임시 파일에 대해 걱정할 필요없이 내부에서 파일을 수정할 수 있습니다.
예를 들어, 다음과 같은 경우 :
grep 'something' somefile.txt > somefile.txt
somefile.txt가 비게됩니다. 따라서 스폰지를 사용할 수 있습니다.
grep 'something' somefile.txt | sponge somefile.txt
Rsync 는 대부분의 파일 전송 방법 (scp, rcp, piped tar 명령 등, 심지어는 cp)을 효율적이고 강력한 방식으로 대체 / 보완합니다.
다양성으로 인해 많은 옵션이 있습니다. 그러나 적어도 rsync의 기본 사항을 배우는 것이 좋습니다.
mtr 은 traceroute 대체품입니다 (ping과 traceroute의 조합 임).
traceroute와 달리 경로를 거의 즉시 찾습니다 (다음 홉으로 이동하기 전에 응답을 기다리지 않기 때문에).
커맨드 라인 버전은 기본적으로 데비안 (패키지 mtr-tiny)에 설치됩니다.
상황에 맞는 자동 완성.
글쎄, 그것은 명령 이 아니며 많은 Unices에서 발견되지 않을 것입니다. 내 우분투 하디에서 bash_completion
이미 매우 잘 구성하고 있음을 의미 뿐만 아니라 파일과 direcotires을 위해! 예를 들어 내가 입력하면
svn pr<TAB><TAB>
나는 얻다:
praise propdel propedit propget proplist propset
그리고 심지어
svn propget svn:k<TAB>
나는 자동적으로 얻는다
svn propget svn:keywords
그것은을 위해 또한 작동 ant
하고 make
자동으로 기본 파일이나 명령 줄에 지정된 사람을 읽는! 실시간 보호기입니다!
rsh
/ rexec
/ rcp
/ 등 ssh
/ scp
/ etc에 의해 대체되었습니다 .
질문과 태그는 모순됩니다. Linux는 Unix (stupid Open Group)가 아니며, 대부분의 "실제"Unix 박스는 Linux가하는 소프트웨어와 가까운 곳에 없습니다. 예를 들어, 상당히 평범한 AIX 5.3pl6 설치에서 :
$ 덜 ksh : less : 찾을 수 없습니다.
그렇습니다. 이러한 시스템을 관리하지만 현장에서 배포 된 시스템과 일치해야하므로 대부분의 경우 비 핵심 구성 요소를로드하지 않기로 합의했습니다.
도구 상자에 최신 도구를 사용하는 것이 좋지만 "오래된 학교"방식을 모른다면 AIX / Solaris / HP-UX를 사용하는 경우 상처를 입을 수 있습니다. / etc 시스템에는 최신 도구가 없으며 bash가 없을 수도 있습니다.
개발 VM에는 찾을 수있는만큼 많은 최신 도구가 설치되어 있습니다. 더 평범한 환경에서 작업 할 수 있지만 즐기라는 의미는 아닙니다. 그리고 Linux (CentOS 5) 시스템에서 가능한 한 많은 작업을 수행합니다. 단순히 해당 도구가 AIX 용 패키지로 쉽게 찾을 수있는 것보다 훨씬 새롭기 때문입니다 (Solaris가 다소 우수합니다. HP-UX는 무한히 나쁩니다).
netcat
should be universally replaced by socat
.
It's worth having a look at the GNU versions of some commonplace commands, since they've quietly acquired useful refinements beyond the standard (XPG4, etc.) versions.
For example, recursive grep is much nicer than find | xargs grep
.
Also, find ... -print0 | xargs -0 ...
handles the long-standing horrible quoting problem that makes xargs fail to handle funky space-filled filenames properly.
GNU tar takes 'j' and 'z' flags to handle bzipped and gzipped archives directly.
And bash's $()
alternative to backticks makes the occasional nested backquoted expression easier to read and write.
On Linux, ip
(from the iproute2
package) behaves more predictably and gives easier-to-parse output than ifconfig
/route
.
pax
is a replacement for tar
and cpio
, with a sane set of command-line options: -r
to read from an archive, -w
to write to an archive, -rw
to do tree-to-tree copies. It also provides a -s
option to allow you to perform substitutions on filenames before reading/writing a file from/to an archive. :-)
Edit: Mark Baker makes an interesting point (in comments) that I should clarify. pax
makes pax
archives (which are an extension of ustar
, and can be unpacked by most tar
programs) by default. But, with the -x
option, it can be made to create cpio
archives and ustar
archives (these two are guaranteed by the standard). Some implementations, such as the BSD one, support creating even more types, such as old-style (pre-ustar
) tar
archives.
One might say that awk
has been completely obsoleted by perl
.
However, since I was using awk since before perl existed, I still use it; as for more serious scripts, I use python instead of perl.
atool: handling archives without headaches
Some examples:
- aunpack archive.tgz Unpacks all the files in the archive. If the author of the archive was so inconsiderate as to put multiple files in the archive’s root, the command automatically creates a directory and moves the files inside.
- aunpack -e archive1.tgz archive2.zip Unpacks each archive.
- apack archive.tar.bz2 *.txt Creates a new compressed archive containing all text files in the current working directory.
- als archive.rar Shows the names of the files contained in the archive.
Examples are from: http://debaday.debian.net/2008/12/28/atool-handling-archives-without-headaches/
dig
is a better alternative to nslookup
.
'rename' is a good alternative to the long oneliners one writes to change name to a bunch of files.
Not really a replacement for an outdated command per se, but screen is a great alternative to opening multiple terminal windows and/or using bg, etc.
If you're on a GNU system, don't use sed '1!G;h;$!d'
; instead, use tac
.
bm (link), instead of popd and pushd or creating temporary aliases, is really useful.
To add a directory to be called with tag
bm -a /path/to/a/dir tag
To go to this directory
cdbm tag
Wherever glibc
is installed, you can getent passwd foo
instead of grep foo /etc/passwd
(similarly for aliases ethers group hosts netgroup networks protocols rpc services shadow
) -- it even Does The Right Thing(TM) in an NIS setup.
Why bother typing gzip -dc foo.tar.gz | tar xf -
when tar xzf foo.tar.gz
will spawn the decompressor for you?
Going even further... why bother typing tar xzf foo.tar.gz
or tar xjf foo.tar.bz2
when GNUtar
will automatically detect compression? tar xf foo.tar.(gz|bz2)
just magically works.
I'm not sure if this should be an answer or merely an edit to the question.
Before using less as a tail replacement, you can search for something "/search_string" and THEN invoke the Follow command (shift-F). Now any "search_strings" that scroll by will be highlighted. This is useful for when you're scanning a bunch of program output or logs and are looking for a particular string or pattern.
Don't forget that you can use regular expressions, too!
cfdisk is an easy-to-use upgrade of the command-line drive partitioning utility fdisk.
ifconfig and iwconfig are deprecated in favor of ip which is a extremely powerful tool to show / manipulate routing, devices, policy routing and tunnels.
echo
might still only be used with trivial arguments otherwise, its behavior might be unpredictable. For all other purposes (control characters, new line suppression, formatting), it has been obsoleted by the much powerful and consistent printf
command.
I really like locate as a substitute for find - much easier to use "locate filepattern" than "find / -name filepattern -print", and more efficient because it uses an index database.
You have to have the updatedb command run on a schedule to update the locate database; check your distro's man page for details.
tmux
over screen
. tmux
is so much easier to configure, it's not even funny.
The Perl Pie: perl -pi -e 's/foo/bar/'
instead of sed 's/foo/bar/'
, with the much more powerful perlre syntax. (It's not quite a drop-in replacement, since Perl regexes use, for example, ?
instead of \?
.)
I find that wcalc is a nice replacement for bc
'Programing' 카테고리의 다른 글
생성자에 super ()를 넣을 필요가 없습니까? (0) | 2020.06.08 |
---|---|
MYSQL이 더 높은 LIMIT 오프셋으로 인해 쿼리 속도가 느려지는 이유는 무엇입니까? (0) | 2020.06.07 |
ClickOnce 응용 프로그램의 폴더 경로를 얻는 방법 (0) | 2020.06.07 |
문자열의 마지막 두 문자를 선택하는 방법 (0) | 2020.06.07 |
호스트 요소에“클래스”를 추가하는 방법은 무엇입니까? (0) | 2020.06.07 |