Simple BASH - I still don't get it.

My special interest is computers. Let's talk geek here.
Post Reply
User avatar
Kellemora
Guardian Angel
Guardian Angel
Posts: 7494
Joined: 16 Feb 2015, 17:54

Simple BASH - I still don't get it.

Post by Kellemora »

Hi Yogi

For some reason BASH goes over my head like a lead balloon.

Here is a line I enter into the terminal by hand. The $ is the end of the Terminal Line of course.

$ date +%A_%I:%M_%p -d "today +12 hours"

I change the +12 to whatever whole number I need, like 4 hours, 6 hours, 8 hours, etc.

This little command takes the current "Date" shown on my computers clock, doh.

%A gives me the full weekday name
%I gives me the hour
%M gives me the minutes
%p gives me am or pm
An _ is the same as a space in the printout.
-d tells it to display as a string.

Nothing in the man pages explain or show a + sign, but it is used in most of the examples.

Only because I know what the output looks like, since I use it everyday, can I figure out the command is telling it how to display before it tells it what to display.

But the way it reads to me, and this is why I'm so confused. It works but why?
To me it says, take the computers date, IN day name, hours and minutes, and display it. THEN it says use this figure and add 12 hours to it. Where is the command to display the answer?
Although it gives the correct answer I want, the way it's written, seems like it should INSTEAD be showing me the computer time and not the correct answer as it does.
Unless it is because the -d is AFTER the How to Display it.
In other words, take the Day Name, Hour, and Minute, which is TODAY and add 12 hours to it, then display.

OK - We know the above works, even if I cannot figure out why for the life of me.

What I need now, and I'm totally in the dark.
Is it possible to add to the above line, so it first shows the answer for the number entered, in this case 12, and also to show a second answer which is exactly double the first hourly entry? With both showing the day name, hour, and minute.
They way I'm doing it now is if I used 12 as in this example, after hitting enter, I would run the command again and type 24 where the twelve currently is entered.

NOT saying this to be funny. But to me, it seems one should be able to use a better format, such as
$ date "today +12 hours" -d +%A_%I:%M_%p
In other words say, Take computer DATE, which is TODAY and add 12 hours, then DISPLAY using DayName, Hours, Minutes. It would be much more logical, hi hi...
ALSO, the words TODAY and HOURS - DO NOT APPEAR on the Man Pages, so how does one learn to write the above script in the first place.

As you know, me and Man Pages have never got along very well, and this is just one of the reasons why.
What I would have needed to know to write this simple Command is NOT in the Man Pages, nor in any Man Page samples associated with DATES, or TIMES. Nor have I found same in any of the Beginner BASH Tutorials I have studied.
Yet someone familiar with BASH can pound out these valuable little gems one right after the other.
Where did they learn to use the "today +12 hours" from if not in any lessons?

OK, not picking on you Yogi, I just get frustrated trying to learn what isn't written there to learn, so cannot do what I want to do. Thankfully, someone else wrote this little script and I'm just trying to figure it out to modify it a little.

FWIW: I tried my switched around code above, first it said I need a + in front of the argument, then for the string with the percents in it, it said Invalid Date, hi hi...
I guess my computer doesn't know an invalid is writing the code, hi hi...

OK, I'm outta here...
All I need is to automatically double the number I enter and show two answers, one for 12 and one for 24 in this case.

IGNORE BELOW DRIVEL, I CAME BACK AND EDITED THIS BECAUSE I SEE IT IS WORKING. I JUST DIDN'T NOTICE THE AM/PM DOH....

HOWEVER, what I really want is where the 24 is in the below line to be a two times multiplier, but based on the number entered in the first area, in this case, where the 12 is.
Since the first answer is for "today +12 hours" somehow it would have to reference that answer to double it.

END OF EDIT

I tried this and do not get the right second answer, as you can see. Have no idea why not either.
$ date +%A_%I:%M_%p -d "today +12 hours"; date +%A_%I:%M_%p -d "today +24 hours"
Wednesday_04:01_AM
Wednesday_04:01_PM

If I try putting a plus in front of the second date I get.
$ date +%A_%I:%M_%p -d "today +12 hours"; +date +%A_%I:%M_%p -d "today +24 hours"
Wednesday_04:04_AM
bash: +date: command not found

Or using a %n to get a new line produces.
$ date +%A_%I:%M_%p -d "today +12 hours"; %n date +%A_%I:%M_%p -d "today +24 hours"
Wednesday_04:09_AM
bash: fg: %n: no such job

OK, done messing around.

TTUL
Gary
User avatar
yogi
Posts: 9978
Joined: 14 Feb 2015, 21:49

Re: Simple BASH - I still don't get it.

Post by yogi »

You are touching upon one of my MAJOR gripes about Linux, and all computers in general. There seems to be no written words telling normal human beings how to use these friggin devices. I thought I was pretty sophisticated when it came to computers until smart phones and tablets came into vogue. My 14 year old granddaughter was more savvy than I am today with this new technology. I don't have a problem with man pages or complex instructions on how to program something, but there are no instructions on how to use Windows 8.1 touchscreen, for example. If you get one of those things, it is assumed you are smart enough to know how to use it beforehand. The problem is even more fundamental than that. Where are the instructions for using a keyboard or mouse? What the heck is "cut and paste" and why would I ever want to use it? None of that is explained anywhere that I know of, yet your computing device is useless unless you know what it all means BEFORE you even turn on that machine.

So it is with BASH. All the help forums and built in technical documentation presumes you know quite a bit before you even turn the power on to your device. The point of all those man pages is to explain something very specific and not to have to give you a history lesson in how to use a computer. The man pages are rigorously organized in a specific format. Show me where the explanation is to understand the format used in man pages. The truth is I recall reading an article one time some thirty or forty years ago where it explained how to read man pages. That kind of information, however, is not included with any Linux OS I know about. And, believe it or not, it was not until today while I was researching your question that I discovered there is something called core utilities info:
  • /usr/share/info/coreutils.info.gz
If you want an explanation of how 'date' works, then you need to enter this instruction into the command line:
  • info coreutils 'date invocation'
And, how did I figure that out? It's at the end, the very last paragraph, of the man page entry for 'date'
Linux MAN page wrote:SEE ALSO
The full documentation for date is maintained as a Texinfo manual. If
the info and date programs are properly installed at your site, the
command

info coreutils 'date invocation'

should give you access to the complete manual.

GNU coreutils 8.21 January 2015 DATE(1)
Going backwards one step, the opening paragraphs of the coreinfo file seems to explain nearly everything you always wanted to know
da
/usr/share/info/coreutils.info.gz
File: coreutils.info, Node: date invocation, Next: arch invocation, Up: System context

21.1 `date': Print or set system date and time
==============================================

Synopses:

date [OPTION]... [+FORMAT]
date [-u|--utc|--universal] [ MMDDhhmm[[CC]YY][.ss] ]

Invoking `date' with no FORMAT argument is equivalent to invoking it
with a default format that depends on the `LC_TIME' locale category.
In the default C locale, this format is `'+%a %b %e %H:%M:%S %Z %Y'',
so the output looks like `Thu Mar 3 13:47:51 PST 2005'.

Normally, `date' uses the time zone rules indicated by the `TZ'
environment variable, or the system default rules if `TZ' is not set.
*Note Specifying the Time Zone with `TZ': (libc)TZ Variable.

If given an argument that starts with a `+', `date' prints the
current date and time (or the date and time specified by the `--date'
option, see below) in the format defined by that argument, which is
similar to that of the `strftime' function. Except for conversion
specifiers, which start with `%', characters in the format string are
printed unchanged. The conversion specifiers are described below.


There is more written than what I reproduced here, of course. I fully understand why it would be daunting to read all that technical gobbledygook when all you want to do is something very simple. Keep in mind that each and every command you enter into the CLI is a small program that gets executed by the kernel. If you look at the kernel coding you will see that there are a ton of low level functions that are called per your instructions. The output of each function is sent to the standard output device unless you specify sending it somewhere else (to a file, for example). That bit of knowledge (plus how to send the output elsewhere) is never explained. All these manual and info pages do is tell you how the given command works at the human being level. The machine level operations are something beyond the scope of the how-to explanations.

I could be wrong, but it looks like you figured out what you want to do. Think of the date as being an integer - epoch time - dug up by the 'date' command. That number can be manipulated and formatted like any other regular expression. The man/info pages explain what formats and manipulations are built into the core commands. What you do with all that power is for you to decide.
User avatar
Kellemora
Guardian Angel
Guardian Angel
Posts: 7494
Joined: 16 Feb 2015, 17:54

Re: Simple BASH - I still don't get it.

Post by Kellemora »

Hi Yogi

Yes I knew about the "info coreutils 'date invocation'" and even have a icon in my panel that takes me to the coreutils index. What is written there is just as confusing and not much different than the man pages themselves. Most are just copies of the man pages anyhow.

Yes I did figure out how to get BOTH lines I wanted, provided I change the numerical value in both places.
It is easier just to keep my terminal open to a single line numeric entry, and after I do it once, use the up arrow key to get back to a previously used entry.

Let's assume I understand how to use the codes supplied in the man pages for date to get the first part of the code I'm using. What I cannot seem to find anywhere is where the part in quotes following it comes from.

CODE - OPTION - FORMAT

$ date +%A_%I:%M_%p -d "today +12 hours"

If date is the CODE
and +%A_%I:%M_%p is the OPTION
and -d is the FORMAT
WHERE do I find out where the "today +12 hours" comes from?

Honestly, I've spent hours reading tons of stuff about BASH and have yet to come across whatever that part in quotes is called, in order to learn about it.

I have over a dozen links to website claiming Beginning BASH, BASH Simplified, EZ BASH Tutorial, Saving Time with BASH, etc. etc. etc. and none of them helped me to write that simple line of code I use, until AFTER someone else did it for me, and added the parts I had left out, namely, the part in quotes.
All I ever got was "Date Option Requires an Argument."
So this means to me, the CODE - OPTION - FORMAT is missing something called - ARGUMENT.
If I do date --help it says the Argument is OPTIONAL and gives the example

After any flags comes an optional field width, as a decimal number;
then an optional modifier, which is either
E to use the locale's alternate representations if available, or
O to use the locale's alternate numeric symbols if available.

OK, if I add the E I get today's date and time printed.
gary@F2A85M2:~$ date +%A_%I:%M_%p -d E
Wednesday_01:00_AM
gary@F2A85M2:~$ date +%A_%I:%M_%p -d O
Tuesday_06:00_PM

By the way, neither of which are correct.
The real time I did this was Wednesday 1:45pm, not 1:00am as shown.
Have no idea how the O caused Tuesday 6:00pm.

Now, how does "today +12 hours" replace the E or the O and why does it give the correct time when the E or O gives the wrong time?

You don't have to answer that, if you know of a website that might explain it, where I can study.

Changing Topics sorta:
I had a code I could type into the RUN box on a WindowsXP 32 bit computer, which didn't work on the new 64 bit computer, even though it was the same OS. All the code did was add to my left mouse button whatever repeat was set for the keyboard keys. Long before I started using KVM switches, I had my \ key remapped to my left mouse button, since I never used the \ for anything.
I had several great autoclickers I could use with windowsXP back when I was playing games, but most of them did not work on 64 bit machines. Then when I converted to using Linux, there are no autoclickers, just codes to cause the left mouse button to repeat, which is basically the same thing as the low end autoclickers.
When I first started using Linux, I had time to play games and hunted for months, then tried writing my own codes by studying BASH and ended up lousing up my computer big time a few times, so just forgot about it.

It just irks me when I find something I can't seem to understand no matter how much I study it.
I figure I'm missing some basic info which is not mentioned in any tutorials.
Like when I started studying php and could not get the examples to work on my own computer.
Nowhere did it say I had to install LAMP first, hi hi...

Funny thing is, back in the days of DOS and BASIC, I was so good and programming for the Apple 6502 using peeks, pokes, and calls, I was offered a job by Beagle Bros. Maybe if I took the job I would have learned C++ too!
When I think of the amount of money I spent back then, on things like Microsoft Macro-assembler and other such programs to convert program codes to EXE files, which I never used more than a couple of times, because I didn't know the programming codes well enough to cover all the what ifs.
Way too long ago to remember the problems I encountered, other than the programs worked great as raw programs, but never worked after being converted to an EXE program. Obviously I was missing something important back then too.

OK, before I burn out your eyeballs. Have a great day Yogi!
Been too busy with work to mess around with anything else. They now have me on 8am to 5:30pm daily, and in a new department which keeps me swamped.

TTUL
Gary
User avatar
yogi
Posts: 9978
Joined: 14 Feb 2015, 21:49

Re: Simple BASH - I still don't get it.

Post by yogi »

Gary ~

I think I have a better understanding of the problem now. Fortunately it's not difficult to explain the theory. Unfortunately, the details will still be yours to work out. Let's examine your example for a moment:

date +%A_%I:%M_%p -d "today +12 hours"

Parsing that amounts to this:
date = the standard Linux built in function to give you the time to which your computer is set.

+ means you want to add formatting to the default output. Remember, the value returned from the 'date' function is an integer representing the number of seconds since 1 January, 1970, or the Epoch Date. That's cool to know, but it's useless as far as us humans are concerned. If you do not add format modifiers, then 'date' by itself will use it's own default format and show you something like this: Wed Jun 3 14:57:58 CDT 2015

Your format options are as follows:
%A = locale's full weekday name (e.g., Sunday). (You want the display to include the spelled out day of the week.)
%I = hour (01..12). (You want the time stated in 1-12 hour format, not a 24 hour format.)
%M = minute (00..59) (You also want the minutes to display from 00 to 59 as appropriate)
%p = locale's equivalent of either AM or PM; blank if not known. (self explanatory)

-d = --date=STRING
display time described by STRING, not 'now'

This last -d parameter is the source of all your consternation (I think). You are specifying an output option here, not a format. You are asking for the output from the 'date' function to be put into a string of characters that is to be displayed on your monitor.
“today +12 hours” is what the string will look like, for which you get:
Thursday_02:18_AM

Two things to note at this point:
1- the underscores (or any other character you put there) will print literally in the indicated positions. Thus, you have an underscore between the %A and %I as well as an underscore between %M and %p.
2- when you specify -d a string definition is expected immediately after it inside quotes. It can be a blank string. If there is no string then the time returned is the beginning of the current day. Your string is expecting to see 'today' to which 12 'hours' is added.


The format options I elaborated on above were taken directly from the man pages. My parenthetical comments are not part of the man pages. ;) The point is that all your format options are listed in the man pages and more or less stated in human language.

To quote the man page opening …
DATE(1) User Commands DATE(1)

NAME
date - print or set the system date and time

SYNOPSIS
date [OPTION]... [+FORMAT]
date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]

DESCRIPTION
Display the current time in the given FORMAT, or set the system date.

Mandatory arguments to long options are mandatory for short options
too.
The NAME of the command is 'date' and it is used to print or set the system date and time.
The way to execute this command is to state 'date' followed by one or more options. The square brackets tell you that position in the command line is for options. In this case you can have many, and if you use FORMAT options, they must be preceded by the plus (+) sign.

The second line of the synopsis is an example of how to write out the available options.

The DESCRIPTION is not always helpful, I'll admit. But in this case it's pretty straight forward and telling you what's going on with 'date'

After the description is a list of all the options. Way at the bottom is an explanation of the DATE STRING option:
DATE STRING
The --date=STRING is a mostly free format human readable date string
such as "Sun, 29 Feb 2004 16:21:42 -0800" or "2004-02-29 16:21:42" or
even "next Thursday". A date string may contain items indicating cal‐
endar date, time of day, time zone, day of week, relative time, rela‐
tive date, and numbers. An empty string indicates the beginning of the
day. The date string format is more complex than is easily documented
here but is fully described in the info documentation.
While use of the string is more or less explained, it is not clear that it MUST follow the -d option and be inside quotes.

At this point you and I are scratching our heads because we don't get what exactly goes inside that required string. Well, the author of the man page could not be bothered to tell us and s/he clearly says that when we are told to go to the info documentation or explanations.

Quoting from the info document:
21.1.6 Options for `date'
-------------------------

The program accepts the following options. Also see *note Common
options::.

`-d DATESTR'
`--date=DATESTR'
Display the date and time specified in DATESTR instead of the
current date and time. DATESTR can be in almost any common
format. It can contain month names, time zones, `am' and `pm',
`yesterday', etc. For example, `--date="2004-02-27
14:19:13.489392193 +0530"' specifies the instant of time that is
489,392,193 nanoseconds after February 27, 2004 at 2:19:13 PM in a
time zone that is 5 hours and 30 minutes east of UTC.
Note: input currently must be in locale independent format. E.g.,
the LC_TIME=C below is needed to print back the correct date in
many locales:
date -d "$(LC_TIME=C date)"
*Note Date input formats::.
The first sentence clearly says it all, but only in a general sense. The specifics of what to put into the string takes several sections (starting at 28.1 General date syntax) of the document to explain. I gave a cursory look for an explanation of 'today' which is part of your DATESTR specification but could not find it.

The information that you are missing is not part of BASH. You were looking in the wrong place. You should have been looking for an explanation of the system utility called date. The system 'date' command is explained in great detail in both man pages and in the core utilities documentation. I empathize with your inability find what you are looking for because in this particular case it is complex and buried deep. But, it IS all there.

If you were able to follow what I said above, then one of your mysteries is easily explained:
  • gary@F2A85M2:~$ date +%A_%I:%M_%p -d E
    Wednesday_01:00_AM
    gary@F2A85M2:~$ date +%A_%I:%M_%p -d O
    Tuesday_06:00_PM
The -d needs to have a quoted string immediately after it in order to return what it is you are looking for. As noted earlier, if the string is missing, or is null, the 'date' function returns the beginning of the day. I have no idea what it is doing when it sees 'E' or 'O' but it's obviously neither the beginning of the day (midnight) nor the current time unless your system time is not set to CDST.
User avatar
Kellemora
Guardian Angel
Guardian Angel
Posts: 7494
Joined: 16 Feb 2015, 17:54

Re: Simple BASH - I still don't get it.

Post by Kellemora »

Thank you Yogi

Believe it or not, your explanation and commentary cleared up a lot of my confusion.
I can use 'today' by itself, or 'today +10 minutes' or 'tomorrow' or 'today +2 weeks' if I was showing the day date.

From what you explained above, I see the +%A etc. is not the format but the format options, and the format is the argument on how and what to display. I also found another name to look under called OPERAND.
The word 'today' or the phrase 'today +20 hours' is the OPERAND.

So, what I have going on in my head right now, which may not be correct, but works is

date [OPTION]... [+FORMAT]... ["OPERAND"]

Technically though, I've not figured out what [OPTION] is. Since my line of code goes.
[FUNCTION]...{+FORMAT]...["OPERAND"]

But at least it is beginning to make a little more sense, on this line of code anyhow.

Thanks Yogi

TTUL
Gary
User avatar
yogi
Posts: 9978
Joined: 14 Feb 2015, 21:49

Re: Simple BASH - I still don't get it.

Post by yogi »

I just spent quite a bit of time trying to find an explanation of the command line notation used in the man pages. While perusing the forums for such documentation I was astounded at some of the replies that were posted for similar quaries. One was "you don't need to know all that. Just type in the command and try things." I didn't feel like signing up for that forum to post my opinion of that reply, but it is typical of what I do not like about Linux. The only enlightenment I found was scattered about in examples from people of widely different levels of knowledge. Most of the useful information was there but could only be gleaned by implication. I don't know all the answers, but I can possibly point you in the right direction. Maybe write a how-to manual in the process. :lol:

The first thing to keep in mind is that any BASH user command is an instruction to run a program. Those programs are typically compiled into the kernel, but they can be in other places too.

You may recall from your own programming days that general purpose programs often need user supplied information to perform the given task. That information is typically appended to the right of the command name. Some command line programs do not need additional information and others accept it as an option and still others have required addition information needs. Linux man pages explain which commands need what.

There is consistency in the man pages layout. The standard sections are:
  • NAME
    SYNOPSIS
    DESCRIPTION
    AUTHOR
    REPORTING BUGS
    COPYRIGHT
    SEE ALSO
Understanding the shorthand that is used in the explanations can be a point of confusion. The next level of confusion is in understanding the significance of the explanations. Learning the significance can often be a matter of trial and error, but the syntax and structure of what the man pages are telling us is assumed knowledge. Hah!

Let's examine some examples of familiar commands.

The clear command is a good example of a command line program that does not need any additional information. Just type the command name into a terminal and it does its job flawlessly. Here is how it's shown in the man page:
clear(1) General Commands Manual clear(1)

NAME
clear - clear the terminal screen

SYNOPSIS
clear

DESCRIPTION
clear clears your screen if this is possible, including its scrollback
buffer (if the extended "E3" capability is defined). clear looks in
the environment for the terminal type and then in the terminfo database
to determine how to clear the screen.

clear ignores any command-line parameters that may be present.

SEE ALSO
tput(1), terminfo(5)

This describes ncurses version 5.9 (patch 20140118).
The name of the command is in the NAME section and the way to use it is described in the SYNOPSIS. Explanations of all the options and requirements is found in the DESCRIPTION section.

The clear command is pretty simple and a great example of a command that needs no additional information to do it's job. We know this because there is nothing in the SYNOPSIS section other than the command name.

Now, let's look at part of the man page for the kill command:
NAME
kill - send a signal to a process

SYNOPSIS
kill [options] <pid> [...]

DESCRIPTION
The default signal for kill is TERM. Use -l or -L to list available
signals. Particularly useful signals include HUP, INT, KILL, STOP,
CONT, and 0. Alternate signals may be specified in three ways: -9,
-SIGKILL or -KILL. Negative PID values may be used to choose whole
process groups; see the PGID column in ps command output. A PID of -1
is special; it indicates all processes except the kill process itself
and init.
We see in the SYNOPSIS that unlike the clear command the kill command needs additional information in order to do its job. The arrowheads and the information therein is shorthand indication for a parameter that is required in order for the command to work. This required information is in the third position of the command right after the options that may be applied and the name of the command. The square brackets indicate possible options you might apply, and those options are explained in great detail in the DESCRIPTION section.

I hear you asking, “Where is the explanation for the […] option?” Good question! It's one of those things for which I could not find an explicit explanation. But, It's fairly intuitive to figure out that the ellipsis marks in brackets means the options can be repeated as required. They could have written the synopsis something like this:
  • SYNOPSIS
    kill [options] <pid> [options] <pid> [options] <pid> [options] <pid> [options] <pid> [options] <pid> [options] <pid> ... as needed
While my example is valid, it contains some ambiguity. You might think all those options are needed but we know they are not. They are needed only if you want to kill more than one process with a single command. The best way to point out “as required” or repeatable options is to show them as ellipsis marks -- repeat as necessary.

Now let's look at the germane parts of the man page for the date command:
NAME
date - print or set the system date and time

SYNOPSIS
date [OPTION]... [+FORMAT]
date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
The first observation to make is that there is no <required> information that you have to pass along to the command in order to make it work. There are possible [OPTIONS], and they can be appended in two different ways:

1- The top line shows multiple options may be appended [OPTIONS]… ahead of another set of options used to format the output [+FORMAT]. The formatting options must be preceded by a plus sign.

2- The second line shows how to use date with universal time options and how to format the output manually. Two sets of options are needed to do this. NOTE: the vertical bars in the first set of options. The bars separate specific elements, -u, --utc, and –universal. These element are mutually exclusive. In other words there are three ways to call universal time but you can only use one of them. The second set of manual format options has options within options.

The date program is very flexible and has a ton of options all listed in the DESCRIPTION section of the man page. In fact there are so many possible options that it boggles the mind to try and understand what they all mean and why you would want to use them. It is not within the purview of the man pages to telly you why you would want to use the commands. Reading the man pages is akin to reading the manual that comes with a new car. The manual will tell you in detail how each gizmo operates, but it will not teach you how to drive the car. That same reasoning is applied by the authors of the Linux man pages. They tell you everything you need to know about the available commands, but they cannot get into why you would want to use the command in the first place.

So, class, the lesson to be learned here is an understanding of what the man pages are telling us and how they go about telling us. In general building commands is something like this:
  • command_name [OPTION] <required parameter> [OPTION1 | OPTION2 | OPTION3]
The name of the command is absolutely required in every case. The number of optional parameters and the order of the elements varies by command
User avatar
Kellemora
Guardian Angel
Guardian Angel
Posts: 7494
Joined: 16 Feb 2015, 17:54

Re: Simple BASH - I still don't get it.

Post by Kellemora »

Wow, thank you Yogi!

You just explained a whole bunch of things I did not know, and never saw written in the tutorials.

So far, the best tutorial I have is the "Advanced BASH Scripting Guide."
It starts out with stuff way over my head, but within later pages and chapters, I find some explanations as to why a line is formatted in such a way.

I have several bookmarks to various BASH tutorial sites, and I've got to the point of renaming the bookmarks by what feature of BASH each covers.
Not once in any of them did I see where ellipsis meant you could repeat the command.

I'm not sure, but I think BASH like commands are used in spreadsheets also, but probably part of the spreadsheet program itself.

I have a question totally unrelated to the above.

Of all the computers I've had around here, if I had a saved document and opened it in the program which created it, it never mattered which computer I was on. It always looked the same on the screen and printed properly.

One of my computers which died in the lightning strike, I temporarily brought back to life to use as my off-line accounting computer. Well it finally died completely, mobo caps all swollen on it too.
I pulled the HD and dropped it in another computer, it booted up OK, but I had to add a couple of drivers for the hardware on the computer I stuck it in. Everything appears A-OK.

I opened a couple of documents and all the pages are off by a couple of lines. I can open the same document from any other computer and it looks as it should and prints as it should, if I'm using the same printer of course.
Once I discovered this, I checked over twenty documents, these are plain text, either as .txt .doc or .odt files, viewed in gedit, libre office writer, or openoffice writer.

If I use the computer where the document is not formatted properly, and make a change to the document. Like just changing a word or two, and leaving the extra line problem alone. It looks right when viewed on the other computers.

I have checked every default setting and I can think of, both on the computer and in the program files on the computer, and the program files are 100% identical, as far as I can see that is. Like the Style Definition reads the same, etc.

Have you ever encountered this?

Now I know when I was running Windows, the margins on word.doc files are linked to whatever printer you have connected to your computer, which is why we had so many problems using word.doc with outside printing companies, and had to have work-arounds for them.
So even back when I used commercial printing companies, as long as I provided .odt files, all of my printing came out perfectly, never a problem.

I've not figured out what is causing this yet. What it means is I cannot use that computer to do my editing or printing from. Don't worry, it's not the Silver computer! An old iMicro cabinet with Asus AMD and Debian 7.
I did reboot back into the original Debian 7 on the original HD and am getting the same problem. So the problem is a new one. Changing screen resolutions has never caused the pages to reformat or change lengths. So I'm stumped, at least for the time being.

Have a great day Yogi! I need to mow the grass before the city gets after me, hi hi...

TTUL
Gary
User avatar
yogi
Posts: 9978
Joined: 14 Feb 2015, 21:49

Re: Simple BASH - I still don't get it.

Post by yogi »

The short answer to your question is no, I never ran into the particular problem you describe. Then again, I don't have quite the same collection of hardware that you have. :mrgreen:

Something in that oddball computer is different, and that difference is what makes the output not the same as the others. Is it hardware, software, firmware, or all of the above? You might be able to narrow it down to software or hardware by judiciously swapping out individual components of the hardware setup. If the hardware is identical and you still get a difference in output, then it's obviously an issue with the software.

Version control of all the drivers is a nightmare. Each component of a typical computer system seems to have it's own requirements for software. If you let the system do the installation on its own, it will pick the drivers that it finds most suitable. Even if the hardware is identical, the different kernels of Debian (or any Linux distro) may contain different "preferred" drivers. Thus the way to assure consistency is to examine all the driver versions you have installed in each system. The kernel and any modules you attached should be identical too. I didn't look at all the possible Linux commands and utilities, but I would bet there is something out there that would look at all the software you have installed, drivers et. al., and tell you their version numbers. I'm guessing something in the oddball computer is ... well ... odd.

The best solution is to use software that is platform independent. The idea of .pdf file format is a step in that direction. I understand that some of your vendors may not agree with that choice of document format, but it does take the hardware variations out of the equation. You could try an experiment and put your document in .pdf and see how it prints on the various devices. That may not tell you where the difference originates, but it will tell you that the printing can be made to be consistent.
User avatar
Kellemora
Guardian Angel
Guardian Angel
Posts: 7494
Joined: 16 Feb 2015, 17:54

Re: Simple BASH - I still don't get it.

Post by Kellemora »

Hi Yogi
Back when I upgraded from Debian 6 to Debian 7, both of my printers began acting up, printing page after page of garbage unless I rebooted the printers, went into their control panel, paused printing and then resumed, I would get one copy, then it would go back to garbage printing again.
This was consistent on all of my computers. Printing worked perfectly in Debian 6, failed every time in Debian 7.
It was so annoying, I kept an older computer booted into Debian 6 just to use for printing. Ironically, the only one the lighting did not destroy, but it has no functioning Ethernet now. I've replaced Ethernet cards in both slots, worked for awhile, but no more.
No problem, I just placed the hard drive with Debian 6 in another computer and it was good to go, until that computer died. Now I have none with IDE ports anymore. Can't clone an IDE drive to a Sata drive with no IDE to do so from.
Debian 8 has the same printing problems as Debian 7. Debian blames CUPS, and CUPS blames Debian, hi hi...

As far as the Documents changing formatting. I have now spent several hours trying different things to see why it is doing it. I even went through the default styles on the offending computer looking for anything which might be different.
This is not as easy as it sounds, because word processing programs show the proper font in the display window for the font, even when that font is not installed. The display looks different, but until you realize it is using a default font for one you don't have installed, it can be frustrating. I checked the fonts and the one called for is installed and in use.

Everything that has to do with page length or number of lines on a page is identical to my other computers, at least in the setting. But the offending computer is displaying two lines less on the display and in print, from what the actual document has set.
I've gone through "Styles & Formatting" checking every single detail, to make sure they were identical with the original, and not changed on the other computer. Since this file is a part of the document itself, naturally it reads exactly the same data under each tab.
I decided to create a new document using Courier 10 Pitch with zero added space below a paragraph.
The same problem of the bottom two lines moving to the next page is consistent with every document tested, regardless of font, margin settings, or anything else I can find, so far.

I did some more tests, by creating a document on the offending computer and moving it to any of the computers which work right. They will display the document with the top two lines from page two at the bottom of page one.
This is telling me it is not the actual word processing programs causing the problem, but something about how documents are displayed on the offending computer.
Changing screen resolutions makes no difference.
I ran out of time for trying other tests in the computers own settings to see if I can find something there which may cause it.

This is a serious problem for me, since one of my job duties is formatting books for printing or conversion to e-books. I can't have what I'm seeing be two lines over what is really on the page. This would throw a 350 page book's formatting off by 700 lines or roughly 14 more printed pages than I should be seeing.

The first thing I did this morning when I logged in at work was send a message to our IT department. I sent them identical text from each computer, each written in their entirety from scratch, no cut no paste. I simply opened the word processor and typed the same text on each computer for submission. I'm hoping something will show up hidden somewhere they can see but I can't. They have a way of seeing I guess the coding under the page.

PDF files remain unchanged, no matter which computer I view them on. They still look correct on the offending computer, as do images, and images of nothing but text, like a scanned image of a page of text.

Even so, when you open a document on a computer, it is supposed to be rendered as the coding inside the page tells it to render, and not deviate from it, unless like I said, it has to use a default font because you don't have the required font installed.

I just thought of something, I wonder if there is a difference between the font files on this computer for the three or four different fonts I've tried. Surely Courier 10 pitch would be universal. I'm going to check that next. My proprietary fonts are all the same version, the only version I own. I'll try that first to see the pages still add two lines at the bottom.

I have the weirdest stuff happen!

TTUL
Gary
Post Reply