[opensuse] Basic Bash Question
Guys, How do I call 'ls' from within a script without it also returning the contents of the present working directory? Here is the line from my script: ls -al /usr/lib/libGL.so* Here is the output: # ./linux/scripts/showLibConfig 250sata.pdf 7857.pdf Bannykh-ArizMedBoard.pdf Bannykh-TennMedBoard.pdf bin broadway.pdf david.asc Desktop Documents linux log Pictures public_html westlaw-renewal_20071129.pdf /usr/lib/libGL.so Config lrwxrwxrwx 1 root root 10 2007-11-09 16:19 /usr/lib/libGL.so -> libGL.so.1 lrwxrwxrwx 1 root root 12 2007-12-16 16:25 /usr/lib/libGL.so.1 -> libGL.so.1.2 lrwxrwxrwx 1 root root 27 2007-12-16 16:25 /usr/lib/libGL.so.1.2 -> /usr/X11R6/lib/libGL.so.1.2 -rwxr-xr-x 1 root root 391344 2007-09-21 20:34 /usr/lib/libGL.so.1.2.sav as you can see, it looks like 'ls' is evaluated before 'ls -al /usr/lib/libGL.so*' gets evaluated. How do I fix this? -- David C. Rankin, J.D., P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Sunday 16 December 2007 18:54, David C. Rankin wrote:
Guys,
How do I call 'ls' from within a script without it also returning the contents of the present working directory? Here is the line from my script:
ls -al /usr/lib/libGL.so*
Here is the output:
# ./linux/scripts/showLibConfig 250sata.pdf 7857.pdf Bannykh-ArizMedBoard.pdf Bannykh-TennMedBoard.pdf bin broadway.pdf david.asc Desktop Documents linux log Pictures public_html westlaw-renewal_20071129.pdf /usr/lib/libGL.so Config
lrwxrwxrwx 1 root root 10 2007-11-09 16:19 /usr/lib/libGL.so -> libGL.so.1 lrwxrwxrwx 1 root root 12 2007-12-16 16:25 /usr/lib/libGL.so.1 -> libGL.so.1.2 lrwxrwxrwx 1 root root 27 2007-12-16 16:25 /usr/lib/libGL.so.1.2 -> /usr/X11R6/lib/libGL.so.1.2 -rwxr-xr-x 1 root root 391344 2007-09-21 20:34 /usr/lib/libGL.so.1.2.sav
as you can see, it looks like 'ls' is evaluated before 'ls -al /usr/lib/libGL.so*' gets evaluated. How do I fix this?
Does calling /bin/ls instead of just ls help? -- Don -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
David C. Rankin wrote:
Guys,
How do I call 'ls' from within a script without it also returning the contents of the present working directory? Here is the line from my script:
ls -al /usr/lib/libGL.so*
Here is the output:
# ./linux/scripts/showLibConfig 250sata.pdf 7857.pdf Bannykh-ArizMedBoard.pdf Bannykh-TennMedBoard.pdf bin broadway.pdf david.asc Desktop Documents linux log Pictures public_html westlaw-renewal_20071129.pdf /usr/lib/libGL.so Config
lrwxrwxrwx 1 root root 10 2007-11-09 16:19 /usr/lib/libGL.so -> libGL.so.1 lrwxrwxrwx 1 root root 12 2007-12-16 16:25 /usr/lib/libGL.so.1 -> libGL.so.1.2 lrwxrwxrwx 1 root root 27 2007-12-16 16:25 /usr/lib/libGL.so.1.2 -> /usr/X11R6/lib/libGL.so.1.2 -rwxr-xr-x 1 root root 391344 2007-09-21 20:34 /usr/lib/libGL.so.1.2.sav
as you can see, it looks like 'ls' is evaluated before 'ls -al /usr/lib/libGL.so*' gets evaluated. How do I fix this?
That doesn't make any sense. Could you post the actual code of the script? If the code is as you show it above there is no way that it lists the current directory, unless you have some kind of wierd alias for ls. Type "which ls" without the quotes to see where ls is being run from. -- kr -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Sunday 2007-12-16 at 19:54 -0600, David C. Rankin wrote:
How do I call 'ls' from within a script without it also returning the contents of the present working directory? Here is the line from my script:
ls -al /usr/lib/libGL.so*
Here is the output:
# ./linux/scripts/showLibConfig 250sata.pdf 7857.pdf Bannykh-ArizMedBoard.pdf Bannykh-TennMedBoard.pdf bin broadway.pdf david.asc Desktop Documents linux log Pictures public_html westlaw-renewal_20071129.pdf /usr/lib/libGL.so Config
lrwxrwxrwx 1 root root 10 2007-11-09 16:19 /usr/lib/libGL.so -> libGL.so.1 lrwxrwxrwx 1 root root 12 2007-12-16 16:25 /usr/lib/libGL.so.1 -> libGL.so.1.2 lrwxrwxrwx 1 root root 27 2007-12-16 16:25 /usr/lib/libGL.so.1.2 -> /usr/X11R6/lib/libGL.so.1.2 -rwxr-xr-x 1 root root 391344 2007-09-21 20:34 /usr/lib/libGL.so.1.2.sav
as you can see, it looks like 'ls' is evaluated before 'ls -al /usr/lib/libGL.so*' gets evaluated. How do I fix this?
I can not reproduce your problem here. I wrote a script: cer@nimrodel:~> cat bin/pp ls -al /usr/lib/libGL.so* cer@nimrodel:~> bin/pp lrwxrwxrwx 1 root root 10 2007-11-03 03:01 /usr/lib/libGL.so -> libGL.so.1 lrwxrwxrwx 1 root root 12 2007-11-03 03:01 /usr/lib/libGL.so.1 -> libGL.so.1.2 - -rwxr-xr-x 1 root root 567628 2007-02-18 02:59 /usr/lib/libGL.so.1.0.9631 - -rwxr-xr-x 1 root root 391344 2007-09-22 03:34 /usr/lib/libGL.so.1.2 So, you either have something else in your script that is interfering, or there is a strangely named file(s) in that path. Or an alias, as K.R. Foley sugests. - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4-svn0 (GNU/Linux) iD8DBQFHZd8/tTMYHG2NR9URAhUoAJ9/xlYdNr5tij89bCVYQTaKqhFFcgCdF3/c AB5KJ9H376jcJTiV8yN3XYM= =rYMp -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
K.R. Foley wrote:
That doesn't make any sense. Could you post the actual code of the script? If the code is as you show it above there is no way that it lists the current directory, unless you have some kind of wierd alias for ls. Type "which ls" without the quotes to see where ls is being run from.
I agree that it doesn't make any sense. Here is the script in its entirety: #!/bin/bash echo -e *** /usr/lib/libGL.so Config '\n' ls -al /usr/lib/libGL.so* echo -e *** /usr/lib/libIndirect Config '\n' ls -al /usr/lib/libIn* echo -e '\n' read -p "Strike and Key to See xorg.conf: " key echo -e '\n' tail -n24 /etc/X11/xorg.conf Run it, it just shows a few config files. You will see that is produces a ls of the present directory before doing what it should. Any thoughts? -- David C. Rankin, J.D., P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
David C. Rankin wrote:
K.R. Foley wrote:
That doesn't make any sense. Could you post the actual code of the script? If the code is as you show it above there is no way that it lists the current directory, unless you have some kind of wierd alias for ls. Type "which ls" without the quotes to see where ls is being run from.
I agree that it doesn't make any sense. Here is the script in its entirety:
#!/bin/bash echo -e *** /usr/lib/libGL.so Config '\n' ls -al /usr/lib/libGL.so* echo -e *** /usr/lib/libIndirect Config '\n' ls -al /usr/lib/libIn* echo -e '\n' read -p "Strike and Key to See xorg.conf: " key echo -e '\n' tail -n24 /etc/X11/xorg.conf
Run it, it just shows a few config files. You will see that is produces a ls of the present directory before doing what it should. Any thoughts?
Hi, Your script is wrong. change all your echo to (use double quotes) echo -e "*** /usr/lib/libGL.so Config \n" and all your probs will disappear!! -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Otto Rodusek (AP-SGP) wrote:
David C. Rankin wrote:
K.R. Foley wrote:
That doesn't make any sense. Could you post the actual code of the script? If the code is as you show it above there is no way that it lists the current directory, unless you have some kind of wierd alias for ls. Type "which ls" without the quotes to see where ls is being run from.
I agree that it doesn't make any sense. Here is the script in its entirety:
#!/bin/bash echo -e *** /usr/lib/libGL.so Config '\n' ls -al /usr/lib/libGL.so* echo -e *** /usr/lib/libIndirect Config '\n' ls -al /usr/lib/libIn* echo -e '\n' read -p "Strike and Key to See xorg.conf: " key echo -e '\n' tail -n24 /etc/X11/xorg.conf
Run it, it just shows a few config files. You will see that is produces a ls of the present directory before doing what it should. Any thoughts?
Hi,
Your script is wrong. change all your echo to (use double quotes)
echo -e "*** /usr/lib/libGL.so Config \n"
and all your probs will disappear!!
Thank you Otto, For solving my CRI! I missed that in man bash, but I knew I had to quote the escape sequence. It was a forest for the trees issue. Also, single quotes work just fine as well. The error is really weird. It was the result of the 'echo *' statement. Why it would interpret the *** is also just as strange. -- man bash (line 2988) echo [-neE] [arg ...] Output the args, separated by spaces, followed by a newline. The return status is always 0. If -n is specified, the trailing newline is suppressed. If the -e option is given, interpretation of the following backslash-escaped characters is enabled. The -E option disables the interpretation of these escape characters, even on systems where they are interpreted by default. The xpg_echo shell option may be used to dynamically determine whether or not echo expands these escape characters by default. echo does not interpret -- to mean the end of options. echo interprets the following escape sequences: \a alert (bell) \b backspace \c suppress trailing newline \e an escape character \f form feed \n new line \r carriage return \t horizontal tab \v vertical tab \\ backslash \0nnn the eight-bit character whose value is the octal value nnn (zero to three octal digits) \xHH the eight-bit character whose value is the hexadecimal value HH (one or two hex digits) -- David C. Rankin, J.D., P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Sunday 16 December 2007 20:05, David C. Rankin wrote:
Otto Rodusek (AP-SGP) wrote:
...
Hi,
Your script is wrong. change all your echo to (use double quotes)
echo -e "*** /usr/lib/libGL.so Config \n"
and all your probs will disappear!!
Thank you Otto,
For solving my CRI! I missed that in man bash, but I knew I had to quote the escape sequence. It was a forest for the trees issue. Also, single quotes work just fine as well.
In this case they do, but they're not equivalent. Double quotes do not prevent shell variable references from being expanded. Single quotes do.
The error is really weird. It was the result of the 'echo *' statement. Why it would interpret the *** is also just as strange.
This has nothing to do with the "echo" built-in, per se. Globbing (the process of expanding shell wild-card arguments) logically precedes the invocation of the command whose arguments are generated by the globbing process and is entirely independent of the command for which the expansion is being carried out. Since the glob interpretation of '*' is "zero or more occurrence of any character," putting more than one together is just redundant (they're idempotent).
--
man bash (line 2988)
echo [-neE] [arg ...] Output the args, ...
As I said, echo isn't at issue. Shell wild-card globbing is.
-- David C. Rankin
Randall Schulz -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
David C. Rankin wrote:
Otto Rodusek (AP-SGP) wrote:
David C. Rankin wrote:
K.R. Foley wrote:
That doesn't make any sense. Could you post the actual code of the script? If the code is as you show it above there is no way that it lists the current directory, unless you have some kind of wierd alias for ls. Type "which ls" without the quotes to see where ls is being run from.
I agree that it doesn't make any sense. Here is the script in its entirety:
#!/bin/bash echo -e *** /usr/lib/libGL.so Config '\n' ls -al /usr/lib/libGL.so* echo -e *** /usr/lib/libIndirect Config '\n' ls -al /usr/lib/libIn* echo -e '\n' read -p "Strike and Key to See xorg.conf: " key echo -e '\n' tail -n24 /etc/X11/xorg.conf
Run it, it just shows a few config files. You will see that is produces a ls of the present directory before doing what it should. Any thoughts?
Hi,
Your script is wrong. change all your echo to (use double quotes)
echo -e "*** /usr/lib/libGL.so Config \n"
and all your probs will disappear!!
Thank you Otto,
For solving my CRI! I missed that in man bash, but I knew I had to quote the escape sequence. It was a forest for the trees issue. Also, single quotes work just fine as well.
The error is really weird. It was the result of the 'echo *' statement. Why it would interpret the *** is also just as strange.
multiple * characters in a row (without any intervening characters) are just redundant, and have no effect beyond the first * run these two commands echo * echo *** echo * is essentially ls with no arguments
--
man bash (line 2988)
echo [-neE] [arg ...] Output the args, separated by spaces, followed by a newline. The return status is always 0. If -n is specified, the trailing newline is suppressed. If the -e option is given, interpretation of the following backslash-escaped characters is enabled. The -E option disables the interpretation of these escape characters, even on systems where they are interpreted by default. The xpg_echo shell option may be used to dynamically determine whether or not echo expands these escape characters by default. echo does not interpret -- to mean the end of options. echo interprets the following escape sequences: \a alert (bell) \b backspace \c suppress trailing newline \e an escape character \f form feed \n new line \r carriage return \t horizontal tab \v vertical tab \\ backslash \0nnn the eight-bit character whose value is the octal value nnn (zero to three octal digits) \xHH the eight-bit character whose value is the hexadecimal value HH (one or two hex digits)
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (7)
-
Aaron Kulkis
-
Carlos E. R.
-
David C. Rankin
-
Don Raboud
-
K.R. Foley
-
Otto Rodusek (AP-SGP)
-
Randall R Schulz