- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Shell Puzzle
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 03:47 AM
03-06-2002 03:47 AM
in our Unix-Class here, s'one came up with this idea:
touch " "
touch " "
So, now we have two files, each with only whitespaces in their name. How can we:
1) access each file selectively
2) make the whitespaces visible
ls -b does not do the trick, as whitespaces are not "non-printing" as such.
Anyone ever run into this ?
Regards
Dan
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 03:50 AM
03-06-2002 03:50 AM
Re: Shell Puzzle
if you call the files with the vi- command, it shows the file name in the left bottom corner marked with ""- characters.
filename " "
Allways stay on the bright side of life!
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 03:56 AM
03-06-2002 03:56 AM
Re: Shell Puzzle
Ciao
Federico
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 03:56 AM
03-06-2002 03:56 AM
Re: Shell Puzzle
sorry, i forgot to mention how to access the files:
ls -l " " in the directory or:
ls -l /path_to_file/" "
rm /path_to_file/" "
rm ./" "
Allways stay on the bright site of life!
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 04:05 AM
03-06-2002 04:05 AM
Re: Shell Puzzle
The first filename is 4 Whitespaces.
The second is 1 Whitespace.
Which makes it kind of hard.
How do do I handle a file by Inode Number ?
Regrds
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 04:08 AM
03-06-2002 04:08 AM
Re: Shell Puzzle
try
ls -b|while read line
do
echo filename \"$line\"
done
Then you have the names neatly between brackets
and can use the data
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 04:10 AM
03-06-2002 04:10 AM
Re: Shell Puzzle
Do the following things & see its output. You can use backslash (\) for special characters like blank spaces etc.
touch " "
echo "hello" >> \
cat \
Hope this helps
Vasu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 04:14 AM
03-06-2002 04:14 AM
Re: Shell Puzzle
try this command:
cat/more /path_to_file/" "
cat/more /path_to_file/" "
or the same syntax with each command. You simply have to quote the space characters.
If you want to find out, how many space- characters are in the name, use the following command:
vi /path_to_file/" *"
Allways stay on the bright side of life!
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 04:22 AM
03-06-2002 04:22 AM
Re: Shell Puzzle
if you'd put that in a shell, you can arg it, like
# prm \ *
(UNTESTED)
#!/opt/perl/bin/perl
opendir D, ".";
my @files = grep { -f } readdir D;
for (@ARGV){
foreach my $f (@files) {
$f =~ m/$_/ or next;
print "rm [$_] ? ";
scalar
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 04:54 AM
03-06-2002 04:54 AM
Re: Shell Puzzle
sorry, typo in last posting of mine:
ls -l /path_to_files/" *"
--> lists all files beginnig with a space, you would get two entries
vi /path_to_files/" *"
--> would open all files beginning with a space, one after the other and show you the names with visible spaces
Then, when you know the number of spaces, you can quote the file name when using the needed commands:
cmd "number_of_spaces"
or
cmd " *"
Allways stay on the bright side of life!
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 08:14 AM
03-06-2002 08:14 AM
Re: Shell Puzzle
thanks to you all. vi seems to be the only
"readymade" solution here. I have not tried the Perl thing. I'll let you know on that.
Thanks again.
Regards
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 08:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2002 08:35 AM
03-06-2002 08:35 AM
Re: Shell Puzzle
To access the files, quote them: surround the appropriate number of spaces with "".
To list multiple files beginning with a space:
ls " "*
Note the asterik is following the quotes, not inside.
To make the spaces visible you could do:
ls " "* | tr " " .
The output would be:
.
....
To see what characters are in the file names:
ls | od -b
0000000 040 012 040 040 040 040 012
0000007
Note 012 is a newline which delimits filenames in this output.
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2002 06:19 AM
03-07-2002 06:19 AM
Re: Shell Puzzle
Adding to the other responses:
Let's first make some files *with* a content:
echo one >' ' # One space.
echo four >' ' # Four spaces.
> 1) access each file selectively
General:
command './ ' # One space.
command './ ' # Four spaces.
I.e. for *example*:
$ cat './ ' # One space.
one
$ cat './ ' # Four spaces.
four
$
> 2) make the whitespaces visible
ls -1 | cat -e
$
$
[other filenames]
$