nixCraft Linux / UNIX Newsletter

Link to [RSS/Feed] nixCraft: Linux Tips, Hacks, Tutorials, And Ideas In Blog Format

How to gzip and keep original file on Unix or Linux command line

Posted: 21 Mar 2016 12:11 PM PDT

I would like to compress a log file using gzip Unix command line utility, and I would also like to keep the original file. However, when I use the gzip my-app.log command, results in modifying my log file and renaming it my-app.log.gz. How do I force the gzip command to keep original file while maintaining the original file on Linux or Unix-like system?

Unix / Linux: Remove duplicate lines from a text file using awk or perl

Posted: 21 Mar 2016 08:16 AM PDT

I have a text file with exact duplicates of lines. I need to remove all those duplicates lines and preserves the order too on Linux or Unix-like system. How do I delete duplicate lines from a text file? You can use Perl or awk or Python to delete all duplicate lines from a text file […]

Linux: lxc forcefully stop and kill container

Posted: 21 Mar 2016 07:37 AM PDT

I want to stop the application running inside a container. I issued lxc-stop -n myapp but the command is not returning to the shell prompt, and my lxc container entered in hang state. How do I kill my container running on Ubuntu Linux host?