Question:
how can i work with files with spaces in their names while using UNIX shell commands????
just_solved
2007-08-19 10:19:15 UTC
while using awk command with ls ,i found that it creates different two columns for the same file if the has a space in it's name ......can anyone tell me how to deal with it??
Six answers:
McFate
2007-08-19 18:50:34 UTC
awk splits columns on both tabs and spaces by default. You can use the -Fc command-line option, to split on character "c" instead, if that will help. For example, you can split columns on tabs only, if there are tabs between columns and spaces in filenames only.



If you have some spaces which delineate columns, and some which do not, then it is not as simple as splitting on spaces or not splitting on spaces, and awk is probably not the right tool for the job. You'll have to come up with some way to tell which spaces break columns and which don't. Without more details, I don't know exactly what you're trying to do, or if it is practical to get a different input format that's easier to split. Anyway, you might do better with sed or perl, or at least something other than awk, to parse the individual lines.



If you're running "ls" through awk, why not just use "ls -1" (list as a single column) and treat each individual line as a full filename, spaces or not? No reason to use awk if you're NOT trying to peel off columns.
welpen2004
2007-08-19 11:13:28 UTC
In UNIX, filenames are case-sensitive. All that means is that UNIX treats upper and lowercase letters as distinct in a filename.



For example, the filename Aunt_Betty is a different filename than aunt_betty.



File Extensions

Often, you'll see filenames that include something called an extension. For example, if I had a set of documents that I created with my favorite word processor I might give them filenames like:

paper1.doc

paper2.doc

short_essay.doc

resume.doc



These files have names just like the files mentioned before, the only difference is that these filenames all end in .doc. The .doc part of the filename is what we call the extension and the part before .doc is called the base: . Note that paper1.doc is just a filename just as paper1 is a filename and, in that sense, the extension is nothing special.



We use extensions in order to give information about the format in which information is stored in a file as part of its filename itself. For example, I used .doc above to indicate files that were prepared by my word processor.



Extensions, by convention, begin with a period and are usually followed by a short abbreviation. For example, if I prepared some text with an editor (like Emacs) and then wanted to store that in a file, I might name that file something.txt.



Historically, it has become common to use extensions in this way. For certain file formats, common extensions are often used. For example,



.doc

a file prepared by a word processor.

.txt

a plain text file.

.c

source code for a program written in the C language.

.bak

a backup copy of another file.

It should be noted that you can often choose whatever extensions you want; however, there are some common ones that most people use for certain file formats and you should use them. Furthermore, some programs will require you to put certain extensions on files in order to deal with them properly. After time, you will become familiar with what extensions are commonly used, and when certain extensions are required.



If You can't solve it with this explainations it would be helpful if You would take tuition from Unix programmer for about 10 hours. Because this is basic knowledge...
edison
2016-10-10 17:13:39 UTC
Linux, for downloads it has the Transmission Torrent Downloader equipped in, such as you mentioned firefox is the ****, equipped in, you will get and use OpenOffice, its unfastened, and has all the Microsoft workplace courses in similiar variations, you utilizing Linux is a no-brainer, there are some video games yet, in case you decide directly to play something complicated center interior the destiny, then dont swap
2007-08-19 10:23:37 UTC
Try using an underscore like the one in your Yahoo answers handle.

Avatarxz
2007-08-19 10:31:25 UTC
use a backslash before the space.

eg /home/asdf/my\ file/xxx
chharsha
2007-08-19 10:27:45 UTC
try double quotes


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...