1833056 Members
2709 Online
110049 Solutions
New Discussion

Re: Special char

 
SOLVED
Go to solution
WW451512
Advisor

Special char

Hi All..

# ls
f1 f2 f3 f4 f5 r4 t1 t2 t3 t4 t5 t6 test1 test3


# ll t*
t* not found

# ll t?
t? not found

# ls t* <<<< wildcard not working
t* not found

It is NOT treating "*" as a wildcard but as a normal character.

Entry for root in passwd file:
root:EvTwA3Xd/eKd2:0:3::/:/sbin/sh

But when i reload the shell
# /sbin/sh
# ll t* <<<< work fine

How can I correct this problem?

Thanks..
7 REPLIES 7
Raj D.
Honored Contributor

Re: Special char

what happens if you try: # ll | grep ^t
" If u think u can , If u think u cannot , - You are always Right . "
Raj D.
Honored Contributor

Re: Special char

WW451512,
To see the files with special charcter you can open in vi in set list mode and you can find the files those got special character, that doesn't show up in normal ls -l.

1.# ls -l > list.txt
2.# vi list.txt
: set list

3. Delete & modification of filenames you can do with find command with inum option.
To see inode numbers to corresponding files you can use # ls -lai


Cheers,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Raj D.
Honored Contributor

Re: Special char

WW, I think I misunderstood the problem in the earlier reply,

> But when i reload the shell
# /sbin/sh
# ll t* <<<< work fine

- Seems to be problem with your shell.
- After login check the shell, # echo $SHELL

hth,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
WW451512
Advisor

Re: Special char

Following commands were ran in given order:

# echo $SHELL
/sbin/sh

# ll t*
t* not found

but, when I do:
# /sbin/sh <<<< reload the same shell
# ll t*
-rw-rw-rw- 1 root sys 0 Aug 8 15:27 t1
-rw-rw-rw- 1 root sys 0 Aug 8 15:27 t2
-rw-rw-rw- 1 root sys 0 Aug 8 15:27 t3
-rw-rw-rw- 1 root sys 0 Aug 8 15:27 t4
-rw-rw-rw- 1 root sys 0 Aug 8 15:27 t5
-rw-rw-rw- 1 root sys 0 Aug 8 15:27 t6
-- --
-- --

# echo $SHELL
/sbin/sh
Matti_Kurkela
Honored Contributor
Solution

Re: Special char

Perhaps someone has added the "set -f" command to root's ~/.profile?

"set -f" disables "file name generation", also known as "pathname expansion" - and that includes wildcard character processing.

The /etc/profile and ~/.profile are executed only when the shell is invoked as a _login_ shell: reloading the shell within the same session does not re-run those login scripts.

All the exported environment variables and ulimit settings are automatically inherited by the new "child" process from its parent, so running the login scripts is not necessary to have them at correct settings in the "child" shell. But all the non-inheritable shell settings (aliases, shell functions, "set" settings etc.) will be lost. This explains why the wildcard processing works normally in the reloaded shell.

There is a special environment variable $ENV that can be used to make non-login ("child") shells execute a script at start-up. But it is not set by default, and surprisingly many sysadmins don't know about it.

MK
MK
Dennis Handly
Acclaimed Contributor

Re: Special char

>MK: Perhaps someone has added the "set -f" command to root's ~/.profile?

Ah. You can check by:
set -o

You should either see -f or noglob.

>$ENV ... surprisingly many sysadmins don't know about it.

Hmm, that was one of the first things I learned in Real Shell Programming 101. :-)
First that you copy it from someone else, then exactly what that arcane command did.
WW451512
Advisor

Re: Special char

Thanks Matti & Dennis.

Checked /etc/profile and found an entry of "set -f" in the end.

Also "set -o" confirmed the noglob was 'on'.


That was a fantastic catch..thanks again.