Bash Help
-
I have a .txt file which is having
title:
ticketnumber:
createdate:2021-08-17T00:00:00.555
lastupdatedate:2021-08-17T05:00:00.11
assignedgroup:I want to get only the date details from the ticketnumber dont need the values after T.how to do this in bash?
cut command is working but its not showing the full data if i use it
-
@laksh1999 said in Bash Help:
cut command is working but its not showing the full data if i use it
If cut was working, it would show the entire result.
Please post the cut command that you are using.
Also, this is a cut question, not a BASH question.
-
@scottalanmiller said in Bash Help:
@laksh1999 said in Bash Help:
cut command is working but its not showing the full data if i use it
If cut was working, it would show the entire result.
Please post the cut command that you are using.
Also, this is a cut question, not a BASH question.
title:Test Ticket how are you
ticketnumber:D000000000
createdate:2021-08-17T00:00:00.555
lastupdatedate:2021-08-17T05:00:00.11
assignedgroup:GroupI am in need to cut only the createdate and lastupdatedate only .How to do this ?
cut -b 1-23 data.txt
-
@laksh1999 said in Bash Help:
@scottalanmiller said in Bash Help:
@laksh1999 said in Bash Help:
cut command is working but its not showing the full data if i use it
If cut was working, it would show the entire result.
Please post the cut command that you are using.
Also, this is a cut question, not a BASH question.
title:Test Ticket how are you
ticketnumber:D000000000
createdate:2021-08-17T00:00:00.555
lastupdatedate:2021-08-17T05:00:00.11
assignedgroup:GroupI am in need to cut only the createdate and lastupdatedate only .How to do this ?
cut -b 1-23 data.txt
There are much better ways than trying to do string manipulation with bash and small utilities.
I suggest any scripting language that you might be familiar with, for instance perl, php, python etc. It's easy to do what you want with any programming language.
Bash and utilities such as awk, sed, grep, cut etc are excellent for simple, quick and dirty hacks. But when you want to extract data from files and perhaps reformat it, it's much easier to do it with a more suitable tool. Perl in fact was made by a sysadmin for this specific purpose.
-
@pete-s his source data is
json
-
@jaredbusch said in Bash Help:
@pete-s his source data is
json
So even more reason to use a scripting language then.
Both php and python can read and write json files natively. It looks like perl needs to have a module installed.
-
@pete-s said in Bash Help:
@jaredbusch said in Bash Help:
@pete-s his source data is
json
So even more reason to use a scripting language then.
Both php and python can read and write json files natively. It looks like perl needs to have a module installed.
Since there is a restriction installing modules in my developer desktop so only trying without python
-
@laksh1999 said in Bash Help:
@pete-s said in Bash Help:
@jaredbusch said in Bash Help:
@pete-s his source data is
json
So even more reason to use a scripting language then.
Both php and python can read and write json files natively. It looks like perl needs to have a module installed.
Since there is a restriction installing modules in my developer desktop so only trying without python
I understand but using bash and small utilities is like trying to perform surgery with a hacksaw.
I'd look into getting the right tools installed on your desktop before wasting more time on trying to come up with some inflexible bash script.
My personal preference is actually php. A lot of people think it's just for web development and don't realize it's actually a script language that you could use for anything.
-
@pete-s said in Bash Help:
My personal preference is actually php. A lot of people think it's just for web development and don't realize it's actually a script language that you could use for anything.
Rarely use it for that specifically, but PHP is definitely an awesome general purpose scripting language. I especially like that it is so good for web and great as a gp scripting language. So you get the best of one and one of the best of the other.
I like Python a lot, too. And it covers the same range of things as PHP. But I like PHP better.