Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The linux tail command creates a self-extracting tar file

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "linux tail command to create self-extracting tar file", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn the "linux tail command to create self-extracting tar file" bar!

The Tail command parameter has a parameter-n,-- lines=N, which can directly output the * * N lines in a file.

With this parameter, combined with the tar command, you can create a self-decompression similar to winrar under windows under linux.

#! / bin/sh

[$#! = "1"] & & echo "Usage: $0 tarfile" & & exit 0

DESTFILE= "$1.sh"

Echo "#! / bin/sh" > $DESTFILE

Echo "LINES=\ `wc-l\ $0 | awk'{print\ $1}'\ `" > > $DESTFILE # calculate the number of lines in the target file

Echo "LINES=\ `expr\ $LINES-4\ `" > $DESTFILE # calculates the lines that need to be output, which is the total number of lines-4 (4 lines execute script)

Echo "tail-n\ $LINES\ $0 | tar-xv" > > $DESTFILE # output and release (you can release the compressed file in combination with-zmermerj)

Echo "exit 0" > > $DESTFILE

Chmod + x $DESTFILE

Cat $1 > > $DESTFILE # add the tar file to the end of the file

At this point, I believe you have a deeper understanding of the "linux tail command to create self-extracting tar files". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report