LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-08-2014, 01:37 AM   #1
srinu.kadem
LQ Newbie
 
Registered: May 2014
Posts: 2

Rep: Reputation: Disabled
How to redirect output of query result txt file into tar


Dear Team,

Please let me know in signle command, whether I can archive the result of query.

For example, I want below series of sequence commands in one liner command.

-bash-3.2$ ls -ltr > output.txt
-bash-3.2$ tar -zcvf output.txt.tar.gz output.txt
output.txt
-bash-3.2$ rm -fr output.txt


Thanks in advance
 
Old 05-08-2014, 02:37 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
1) man tar
2) search for /standard input
3) i think it would be sth like: command | tar arch.tar.gz - (where the last "-" means: read from standard input)
 
Old 05-08-2014, 03:57 AM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,863
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
For a single file tar is not needed, so:

Code:
ls -ltr | gzip >output.gz
 
Old 05-08-2014, 04:24 AM   #4
srinu.kadem
LQ Newbie
 
Registered: May 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thumbs up Thanks a lot :-) It is working perfectly.

Thanks a log once agian.

Quote:
Originally Posted by NevemTeve View Post
For a single file tar is not needed, so:

Code:
ls -ltr | gzip >output.gz
 
  


Reply



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
redirect sql result to a file ShaqDiesel Programming 1 11-05-2008 02:28 PM
tar, split, burn to dvd result to tar file corruption fedusr Fedora 8 11-30-2007 04:39 PM
How do I output the result of a query in php? orfiyus Programming 0 07-19-2007 02:33 PM
How to redirect txt file to password input? saravkrish Linux - General 3 04-01-2006 02:23 AM
mySQL redirecting query result to a .txt file! buttersoft Linux - Software 8 12-12-2003 03:05 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:33 PM.

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