English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

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??

2007-08-19 06:19:15 · 6 answers · asked by just_solved 2 in Computers & Internet Programming & Design

in a shell program, i have to use "ls" command while operating with "awk "..........this is creating problem for files with spaces in their names ............ awk is treating name of these filenames as two words ,how to rectify this problem?

2007-08-19 06:41:48 · update #1

6 answers

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.

2007-08-19 14:50:34 · answer #1 · answered by McFate 7 · 0 0

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...

2007-08-19 07:13:28 · answer #2 · answered by welpen2004 2 · 0 0

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

2016-10-10 13:13:39 · answer #3 · answered by edison 4 · 0 0

Try using an underscore like the one in your Yahoo answers handle.
Avatarxz

2007-08-19 06:23:37 · answer #4 · answered by Anonymous · 0 1

use a backslash before the space.
eg /home/asdf/my\ file/xxx

2007-08-19 06:31:25 · answer #5 · answered by Anonymous · 0 0

try double quotes

2007-08-19 06:27:45 · answer #6 · answered by chharsha 3 · 0 0

fedest.com, questions and answers