LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 12-09-2010, 11:10 AM   #1
jcardoza
LQ Newbie
 
Registered: Jun 2009
Posts: 23

Rep: Reputation: 0
Question 2 files different time format (need to fix it)


I have 2 files

file1=07:42
file2=10:30:12

I need to compare, but at this moment I have a different format for each one.

Does anyone can helpme to get the same format for both files?

I would like to have hh:mm format is better for me.

Thanks in advance
 
Old 12-09-2010, 11:21 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Not enough input. Is that the sole content of those files?
Is it their name?
 
Old 12-09-2010, 11:26 AM   #3
jcardoza
LQ Newbie
 
Registered: Jun 2009
Posts: 23

Original Poster
Rep: Reputation: 0
name file1 is date_user.txt
name file2 is date_system.txt

date_user.txt
07:42

date_system.txt
10:30:12

Not other thing will have the files, so I need to eliminate the secs from date_system.txt

The idea is have:
date_user.txt
07:42

date_system.txt
10:30
 
Old 12-09-2010, 11:44 AM   #4
thesnow
Member
 
Registered: Nov 2010
Location: Minneapolis, MN
Distribution: Ubuntu, Red Hat, Mint
Posts: 172

Rep: Reputation: 56
You could use cut with : as the delimiter and just take the first two fields, that would give you hh:mm. Assuming that is the only thing in the file.
 
Old 12-09-2010, 11:45 AM   #5
jcardoza
LQ Newbie
 
Registered: Jun 2009
Posts: 23

Original Poster
Rep: Reputation: 0
I found it

cat date_system.txt |cut -c 1-5 > date_system2.txt

Then I have in date_system2.txt
10:30

Thanks for your help.
 
Old 12-09-2010, 11:55 AM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
sed -i 's/^(..:..):.*//' date_system.txt
 
  


Reply

Tags
format, time



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] change one time format to other format himu3118 Linux - Newbie 4 06-21-2010 07:29 AM
Is it possible to format HDDs /fix MBRs using a LiveCD? MrMooncheese Linux - Newbie 2 12-04-2007 08:20 AM
How to convert rm format music files to mp3 format me4linux Linux - Software 2 05-15-2007 01:45 PM
Time format in boot-time messages jonr Linux - Kernel 1 12-22-2006 12:31 PM
Should I format this drive or try to fix all these errors I am getting? M$ISBS General 10 07-02-2006 07:53 PM

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

All times are GMT -5. The time now is 04:28 AM.

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