LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Blogs > linux-related notes
User Name
Password

Notices


Just annotations of little "how to's", so I know I can find how to do something I've already done when I need to do it again, in case I don't remember anymore, which is not unlikely. Hopefully they can be useful to others, but I can't guarantee that it will work, or that it won't even make things worse.
Rate this Entry

[MYSTERY SOLVED] What does "echo ???????????????" really do?

Posted 04-20-2016 at 08:39 PM by the dsc
Updated 04-21-2016 at 05:07 PM by the dsc

It seems to alternate between listing an Nth file (somewhat obscurely related with the number of question marks) on the current folder, or giving some "history" entry, I guess.

That's weird.

Code:
22:54 **ROOT** /# echo ?
?
22:54 **ROOT** /# echo ??
??
22:54 **ROOT** /# echo ???
bin dev etc lib mnt opt run smb srv sys tmp usr var
22:55 **ROOT** /# echo ????
boot home proc root sbin
22:55 **ROOT** /# echo ?????
lib64 media
22:55 **ROOT** /# echo ??????
??????
22:55 **ROOT** /# echo ???????
var-bak vmlinuz
22:55 **ROOT** /# echo ????????
????????
22:55 **ROOT** /# echo ?????????
?????????
22:55 **ROOT** /# echo ??????????
initrd.img
22:55 **ROOT** /# echo ???????????
vmlinuz.old
22:55 **ROOT** /# echo ????????????
????????????
22:55 **ROOT** /# echo ?????????????
?????????????
22:55 **ROOT** /# echo ??????????????
initrd.img.old
22:55 **ROOT** /# echo ???????????????
???????????????

After that, adding question marks just echoed more question marks, as expected.

Code:
22:56 **ROOT** /# ls -1
bin/
boot/
dev/
etc/
home/
lib/
lib64/
media/
mnt/
opt/
proc/
root/
run/
sbin/
smb/
srv/
sys/
tmp/
usr/
var/
var-bak/
initrd.img
initrd.img.old
vmlinuz
vmlinuz.old
22:56 **ROOT** /#

Here's the explanation, "?" is a wildcard!

Quote:
Question mark wildcard

The ? (question mark) is used to match exactly one character. For example three question marks (???) would represent any file name onsisting of three characters. In this example, the rm command would delete all files in the current directory whose names, inclusive of any extensions, are exactly three characters in length:

rm ???

The following would tell the rm command to delete all files in the current directory that begin with the letter z and are six characters in length:

rm z?????

The following would tell the rm command to delete all files in the current directory that have a two-character filename extension:

rm *.??


http://www.cyberciti.biz/faq/unix-rm...ctory-command/

Quote:

19:06 dsc /tmp $ touch 1
19:06 dsc /tmp $ echo ?
1
19:06 dsc /tmp $ touch 12
19:06 dsc /tmp $ echo ??
12
19:06 dsc /tmp $
Posted in Uncategorized
Views 622 Comments 4
« Prev     Main     Next »
Total Comments 4

Comments

  1. Old Comment
    Try
    Code:
    \echo ????
    Posted 04-21-2016 at 06:09 AM by Habitual Habitual is offline
  2. Old Comment
    Code:
    18:07 dsc / $ \echo ????
    boot home proc root sbin
    (Didn't know this inverted dash shorthand for the non-aliased executable, cool)

    Just noticed something similar happens even with printf, with a less "parsed" output (no newlines, as usual), and somewhat different as well:

    Code:
    18:12 dsc / $ printf ????
    boot18:12 dsc / $ 
    18:12 dsc / $ \printf ????
    boot18:12 dsc / $ 
    18:12 dsc / $

    And also with plain bash (I guess):

    Code:
    18:43 dsc / $ bash --norc
    bash-4.3$ echo ????
    boot home proc root sbin
    bash-4.3$

    Eventually I'll boot on Debian to see if it does the same.

    Still on Ubuntu Wily, the mystery-folder/file through "?????" is also present in other commands, such as ls:

    Code:
    18:57 dsc / $ echo ???
    bin dev etc lib mnt opt run smb srv sys tmp usr var
    18:57 dsc / $ ls -1 ???
    bin:
    bash
    bunzip2
    bzcat
    
    [...]
    Posted 04-21-2016 at 04:07 PM by the dsc the dsc is offline
    Updated 04-21-2016 at 04:59 PM by the dsc
  3. Old Comment
    erm,
    I don't know why that didn't "click" earlier.

    Glad it worked out.
    Posted 04-21-2016 at 08:27 PM by Habitual Habitual is offline
  4. Old Comment
    It would probably have been more obvious if I hadn't had the impression that it was somehow echoing history entries, for some reason.
    Posted 04-28-2016 at 08:01 AM by the dsc the dsc is offline
 

  



All times are GMT -5. The time now is 10:36 PM.

Main Menu
Advertisement
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