Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Your syntax for Arithmetic Expansion is incorrect. I suspect you are assuming that `command` == $(command) is equivalent in similar cases.
However, while Command Substitution may be implemented with `command` or $(command), Arithmetic Expansion is only implemented by doing $((expression))
Using `command` is poor form however. It's hard to read and cannot be nested.
An important point to observe here is that you did not know where the error resided in your script.
If you add a "set -xv" line near the start of the script, it would have enabled verbose output and informed you that there was a problem with your mathematical attempt. From there any of the offered solutions to fix that line are applicable.
Usually for time you take the first 10 characters of a files name, what if the file I am looking at has the date within it? File 'Wynyard_MTP_Primary-btstats-2017-03-29-10:34:50.xml'
This is the file I want to do the same the difference between the dates but as it has the date already in it won't I need to do something different?
Usually for time you take the first 10 characters of a files name, what if the file I am looking at has the date within it? File 'Wynyard_MTP_Primary-btstats-2017-03-29-10:34:50.xml'
This is the file I want to do the same the difference between the dates but as it has the date already in it won't I need to do something different?
Cheers
Alex
Now you're looking to match a string.
That can be done with grep and regular expressions. Character Classes and Bracket Expressions may help you here (look in man grep)
For example, to match 4 digits, followed by a dash, then 2 digits I would do something like:
-E, --extended-regexp
Interpret PATTERN as an extended regular expression (ERE, see
below).
-o, --only-matching
Print only the matched (non-empty) parts of a matching line,
with each such part on a separate output line.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.