01-31-2007
Unix filenames and spaces
I have files on my unix boxes that users have created with spaces.
Example: /tmp/project plan
ls -l "/tmp/project plan" works fine.
$/tmp>ls -l "/tmp/project plan"
-rw-r--r-- 1 root other 0 Jan 31 12:32 /tmp/project plan
I created a file called test and put just the line /tmp/project plan in it.
$/tmp>cat test
/tmp/project plan
$/tmp>
$/tmp>for i in $(cat test) do ls -l "$i" done
/tmp/project: No such file or directory
plan: No such file or directory
I have tried to quote this string in and outside of the file everyway possible and I cannot get this for loop to see the spaced file. Any help would be great.
-x96
Last edited by x96riley3; 01-31-2007 at 05:15 PM..
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have a problem with the script below
#!/bin/sh
for vo in `find -maxdepth 1 -type f -regex "^\./*$"`
do
ls -l "$vo"
some other commands
done
It works fine until `find ...` returns files with spaces. I've tryed to change IFS but haven't succeed
Any solutions? (4 Replies)
Discussion started by: Hitori
4 Replies
2. Shell Programming and Scripting
I'm trying to do something like that:
for $filename in `ls -1`
do
some_command $filename
done
but it doesn't work properly for file names with spaces, for...in splits at spaces. Anyway around? (4 Replies)
Discussion started by: rayne
4 Replies
3. Shell Programming and Scripting
Hi All,
I see similar problems in past threads but so far no answers have worked for me. I am trying to write a script which parses a txt file that contains one filename per line, then finds those files on the local disk and copies them to a specified directory.
What I have:
... (4 Replies)
Discussion started by: naviztirf
4 Replies
4. Shell Programming and Scripting
Hi
I hope someone will be able to resolve this little teaser!
I am running a script
for file in `ls directory`
do
echo "$file"
...other code here....
done
this works fine unless we receive a file with a name which has a space in it
ie
"filena me"
(I know its not good... (8 Replies)
Discussion started by: Bab00shka
8 Replies
5. Shell Programming and Scripting
I want to ftp all the sh files in the directory. Also if any of the file name
contains spaces in them, it should be converted to underscores before it is ftped. I wrote the following code below:
FILESSH=$(ls /mysh/*.sh)
--- FILESH being used here for some other task ---
echo "$FILESSH" |... (3 Replies)
Discussion started by: amicon007
3 Replies
6. Shell Programming and Scripting
Hey there, this is my first post and I'll try to explain my situation as best I can.Here is a sample of the input file:
ADO Sample.h,v ADO Sample 2010-05-21 lyonsb /repository/patents/TSCommon/OpenSource/Dundass/ug6mfc/DataSources/Ado/ADO Sample
ADO SampleDoc.h,v ADO SampleDoc 2010-05-21... (3 Replies)
Discussion started by: rodan90
3 Replies
7. Shell Programming and Scripting
I have a problem mounting images because of the spaces in the filenames. Does anyone know how to rename files by removing the spaces with the find command?
find Desktop/$dir -name "*.dmg" -print -exec ??? (4 Replies)
Discussion started by: ianebaj
4 Replies
8. Shell Programming and Scripting
Hi,
I have files like below, In files coming as spaces. Before transfering those files into ftp server. I want to remove the spaces and then can transfer the files into unix server.
e.g: filenames are
1) SHmail _profile001_20120908.txt
2) SHmail_profile001 _20120908.txt
3) sh... (3 Replies)
Discussion started by: kirankumar
3 Replies
9. UNIX for Dummies Questions & Answers
Hello
I've got a certain no. of files in a directory whose names I'm reading and redirecting into a temporary text file using the command below:
ls -l | grep ^- | awk '{print $9}'However, whenever the file names contain spaces the above command considers only the part of the file name up to... (5 Replies)
Discussion started by: S. BASU
5 Replies
10. Shell Programming and Scripting
I'm trying to handle some files with spaces in their name using "" or \ . Like "file 1" or file\ 1.
My current confusion can be expressed by the following shell script:
#!/bin/bash
touch "file 1" "file 2"
echo -n "ls: " ; ls
echo ---
for file in "file 1" "file 2" ; do
echo $file... (9 Replies)
Discussion started by: Ralph
9 Replies
FINGER(1) General Commands Manual FINGER(1)
NAME
finger - user information lookup program
SYNOPSIS
finger [ options ] name ...
DESCRIPTION
By default finger lists the login name, full name, terminal name and write status (as a `*' before the terminal name if write permission is
denied), idle time, login time, and office location and phone number (if they are known) for each current UNIX user. (Idle time is minutes
if it is a single integer, hours and minutes if a ':' is present, or days and hours if a 'd' is present.)
A longer format also exists and is used by finger whenever a list of people's names is given. (Account names as well as first and last
names of users are accepted.) This format is multi-line, and includes all the information described above as well as the user's home
directory and login shell, any plan which the person has placed in the file .plan in their home directory, and the project on which they
are working from the file .project also in the home directory.
Finger may be used to lookup users on a remote machine. The format is to specify the user as ``user@host.'' If the user name is left off,
the standard format listing is provided on the remote machine.
Finger options include:
-m Match arguments only on user name.
-l Force long output format.
-p Suppress printing of the .plan files
-s Force short output format.
FILES
/etc/utmp who file
/etc/passwd for users names, offices, ...
/usr/adm/lastlog last login times
~/.plan plans
~/.project projects
SEE ALSO
chfn(1), w(1), who(1).
AUTHOR
Earl T. Cohen
BUGS
Only the first line of the .project file is printed.
There is no way to pass arguments to the remote machine as finger uses an internet standard port.
4th Berkeley Distribution May 10, 1986 FINGER(1)