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 03-31-2016, 11:03 PM   #1
lonesoac0
Member
 
Registered: Jan 2010
Distribution: Ubuntu
Posts: 95

Rep: Reputation: 4
Trying to capture re-formatted date value


Hello all,

I have a CSV file with the text values of: "3/28/2016" and it includes the quotation marks. As a result, the date command will treat it as text and not a date value and I cannot easily reformat my value to yyyy-mm-dd. I figured out how to remove the quotation marks with:
Code:
variable=${"3/28/2016"//\"/}
. So now I get: 3/28/2016. Here is where I am having difficulties, I can run the command of:
Code:
date -d $variable +"%F"
just fine, but I want to capture it in a variable.

How can I do that?
 
Old 03-31-2016, 11:17 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 15,537

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
Code:
newvar=$(date -d $variable +"%F")
 
  


Reply

Tags
bash, variables


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
Virtual video capture device doesn't show up in Skype or flash capture websites hmbx Linux - Newbie 0 08-10-2015 01:44 AM
Bash script help - Capture output of ls - move files according to date wayneywoo Programming 5 04-23-2013 08:45 AM
Exact time of image capture and Unicap library for video capture devices Dstruct0 Programming 3 09-10-2011 06:34 PM
Running Xvidcap (for screen capture ) + audacity (for audio capture) simultaneously vikram_cvk Linux - Software 2 05-20-2011 03:26 AM
Capture partial output from `date` command tekmann33 Linux - Newbie 7 12-27-2006 01:09 PM


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