LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 05-04-2017, 04:06 AM   #1
ashvini jamdar
LQ Newbie
 
Registered: May 2017
Posts: 10

Rep: Reputation: Disabled
Getting unexpected output from linux script.


Hello,


When we are using find command for finding text file.We are getting .txt file plus .gz file.

We are using below commands

find /opt/tibco/CustomScripts/Daily_Monitoring/ -type f -mtime -2 \! -name '`date "+%b-%dth-%Y-%H:%M"`.txt' -exec gzip {} \;

I want output only .txt file.

I am getting error gzip: /opt/tibco/CustomScripts/Daily_Monitoring/awor-oqtibbw01.010520170200.txt.gz already has .gz suffix -- unchanged



can you please help me.

Last edited by ashvini jamdar; 05-05-2017 at 08:19 PM. Reason: adding error
 
Old 05-04-2017, 04:26 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 16,490

Rep: Reputation: 5532Reputation: 5532Reputation: 5532Reputation: 5532Reputation: 5532Reputation: 5532Reputation: 5532Reputation: 5532Reputation: 5532Reputation: 5532Reputation: 5532
so remove the gzip from the end of the command
 
1 members found this post helpful.
Old 05-04-2017, 06:58 AM   #3
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,940

Rep: Reputation: 780Reputation: 780Reputation: 780Reputation: 780Reputation: 780Reputation: 780Reputation: 780
this more properly belongs in programming please ask a mod to move the thread
 
1 members found this post helpful.
Old 05-05-2017, 08:26 PM   #4
ashvini jamdar
LQ Newbie
 
Registered: May 2017
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
so remove the gzip from the end of the command


Hello,

When we remove gzip from end of script i am getting error find: `/opt/tibco/CustomScripts/Daily_Monitoring/AwOr-PdTibBw01.am.edwards.lcl.050420171600.txt.gz': Permission denied.
 
Old 05-05-2017, 10:36 PM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 21,493

Rep: Reputation: 4107Reputation: 4107Reputation: 4107Reputation: 4107Reputation: 4107Reputation: 4107Reputation: 4107Reputation: 4107Reputation: 4107Reputation: 4107Reputation: 4107
Code:
find /opt/... -type f-mtime -2 ! -name '`date "+%b-%dth-%Y-%H:%M"`.txt' ...
Will find all files modified newer then 2 days ago including *.gz that are NOT the current date/time +%b-%dth-%Y-%H:%M".txt. I assume you want to find just *.txt files that is not the most current.

Code:
find /opt/... -type f -mtime -2 -name '*.txt' ! -name '*`date "+%b-%dth-%Y-%H:%M"`.txt' ...
 
Old 05-10-2017, 11:44 PM   #6
ashvini jamdar
LQ Newbie
 
Registered: May 2017
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
Code:
find /opt/... -type f-mtime -2 ! -name '`date "+%b-%dth-%Y-%H:%M"`.txt' ...
Will find all files modified newer then 2 days ago including *.gz that are NOT the current date/time +%b-%dth-%Y-%H:%M".txt. I assume you want to find just *.txt files that is not the most current.

Code:
find /opt/... -type f -mtime -2 -name '*.txt' ! -name '*`date "+%b-%dth-%Y-%H:%M"`.txt' ...

Thank you for help,above solution is working fine.

Thank you
Ashvini Jamdar
 
  


Reply


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
[SOLVED] C++ unexpected output iceman81 Programming 3 07-26-2016 10:20 PM
unexpected output in perl doughyi8u Programming 4 12-26-2013 10:02 PM
Unexpected output from my program hida4all Linux - Newbie 1 09-08-2010 04:53 AM
Unexpected output from grep zer0x333 Linux - General 12 12-04-2007 10:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:54 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