Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-05-2009, 09:55 AM   #1
LQ Newbie
Registered: May 2005
Distribution: FreeBSD 4.9-5.3, Slackware 10
Posts: 25

Rep: Reputation: 15
Help with advanced tar, ls, and egrep command...

I am migrating users off of a Linux mail server and need to grab the "password" files that the 3rd party mail software package uses for each user. Here is the scenario:


Inside the user#.ext file (text file) is a "LastLogin" date, and I would like to only grab those users that have logged into the mail this current year. On top of that the mail file is in the same directory and I only want to grab the password file. After that if I can tar the files, to send them to another server that would be great.

Has anyone used any deep ls / grep / egrep / tar commands for similar operations?

Any help would be appreciated.

Old 03-05-2009, 12:28 PM   #2
Registered: Sep 2002
Location: Cincinnati
Distribution: Debian GNU/Linux
Posts: 310

Rep: Reputation: 31
# Asserting that user1.ext corresponds to user1.password
# Get the user files for people who have logged in this year
mkdir /tmp/password_files
for user in $(grep 'LastLogin' /var/mail-program/Accounts/*.ext | grep 2009 | awk -F: '{print $1}'); do
    cp -p ${user:0:${#user}-4}.password /tmp/password_files
tar cjvf /tmp/password_files.tar.bz2 /tmp/password_files

for password_file in /tmp/password_files/*.*; do
    shred -vzu $password_file &
rmdir /tmp/password_files


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Tutorial: Advanced Tips For The ps Command LXer Syndicated Linux News 0 10-18-2008 01:50 AM
tar-command not found while compiling glibc-libidn-2.7.tar.bz2 of lfs6.3 aditya_gpch Linux From Scratch 1 05-13-2008 11:27 PM
how to redirect the output of find command to input of egrep babu198649 Linux - Newbie 2 12-27-2007 03:50 AM
egrep to find a command not found string romainp Linux - General 1 09-07-2007 03:30 PM
LXer: Advanced techniques for using the UNIX find command LXer Syndicated Linux News 0 05-04-2006 04:21 AM

All times are GMT -5. The time now is 06:45 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration