LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 01-04-2012, 03:32 AM   #1
t.othoneos
LQ Newbie
 
Registered: Oct 2011
Location: Athens, Greece
Posts: 16

Rep: Reputation: Disabled
stat output to value


Hei everyone and happy new year,

I am trying to input the output of the stat commad to a value like so:

If stat -c %y mail.log.0.gz gives me an output '2012-01-03 04:50:57.000000000 +0200', I am trying to find a way to input the "2012-01-03 04:50:57" part, to a value to use later in a Subject with mutt.

Which would be something like this (i imagine):

This is not code it's logic:

LOGDATE = stat -c %y mail.log.0.gz (without the .000000000 +0200)

then:

mutt -s "BLA BLA $LOGDATE" -a attachment.txt user@domain.com <messagebody.txt

But I can't get it to work.

PlS Help
 
Old 01-04-2012, 03:48 AM   #2
rovf
LQ Newbie
 
Registered: Feb 2010
Location: Germany
Distribution: Suse
Posts: 9

Rep: Reputation: 0
What shell / programming language are you going to use?

In most shells (bash and zsh for instance), $(stat ....) would evaluate to the stdout of the stat command, so you could use mutt -s $(stat ...) ....
 
Old 01-04-2012, 04:14 AM   #3
t.othoneos
LQ Newbie
 
Registered: Oct 2011
Location: Athens, Greece
Posts: 16

Original Poster
Rep: Reputation: Disabled
I use bash. What i actualy need is the last modification date of mail.log.0.gz, ar any file, to go into the subject.
If I must use stat, if there is no other command available, i want to supress the zeros and time zone at the end.
 
Old 01-04-2012, 05:04 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
Code:
stat -c %y filename|cut -d'.' -f1
 
1 members found this post helpful.
Old 01-04-2012, 06:48 AM   #5
t.othoneos
LQ Newbie
 
Registered: Oct 2011
Location: Athens, Greece
Posts: 16

Original Poster
Rep: Reputation: Disabled
Thanx!!! it worked.
 
  


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] Unexpected output from stat --format %h catkin Linux - Software 2 03-07-2010 04:00 AM
understanding stat() output TheIndependentAquarius Programming 5 02-23-2010 01:37 AM
Is this IO Stat output good or bad? abefroman Linux - Server 3 08-11-2008 03:30 PM
Stat command output description jackloo Linux - Newbie 2 09-28-2007 09:31 AM
Cannot stat Input/Output error cygnus-x1 Linux - General 5 08-16-2006 10:48 AM

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

All times are GMT -5. The time now is 08:02 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration