Sponsored Content
Top Forums Shell Programming and Scripting Opening File names with spaces inside it !- PERL Post 302434801 by gameboy87 on Monday 5th of July 2010 07:30:57 AM
Old 07-05-2010
Opening File names with spaces inside it !- PERL

I developed a perl code..And the excerpt from it is given below...


Code:
open(HANDLE,$cmp_path) ; #reading the xml file from the file path
           while($file_path = <HANDLE>)


I have list of XML files to read from a folder. It has some spaces inside the name of the file...I used "\" to escape the space in it. But it is not reading inside the file...When i try to print the XML file in the screen,and open manually, I can open it ! What may be the problem of not opening the XML file in the code even though it is escaped ?

Code:
if($cmp_path =~ m/\s+/g)#check for space
         {
          $cmp_path =~ s/\s+/\\ /g;#replace space by slash
         }
         if($cmp_path =~ m/\&/g)#to check for &
         {
          $cmp_path = s/\&/\ /g;#replace & by \ to open directory
         }

The above code is used to check whether it has space in its name..

My XML may be like the one

Before escaping:

Code:
"werwdfeioutyh rew425-fddf 3425.xml"

After escaping:

Code:
werwdfeioutyh\ rew425-fddf\ 3425.xml

Can you please help me in correcting the perl code i am written?

Last edited by Scott; 07-05-2010 at 08:48 AM.. Reason: Code tags, please...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File names with spaces? Is it possible?

Gurus - I got one simple TXT file with long file name with blank spaces in between the words. I am trying to display that full file name, but it breaks while displaying. Could somebody shed some light here? Script ------ for i in `cat ~\temp\employee.txt` do echo $i done (5 Replies)
Discussion started by: Eric_2005
5 Replies

2. Shell Programming and Scripting

Deleting lines inside a file without opening the file

Hi, Just consider there are around 10 lines in a file. Now is it possible to delete the first 2 lines in the file without opening the file. No matter whatever the content of the file is, I just wanna delete the first 2 lines without opening the file. Is that possible? If so, please help me out.... (3 Replies)
Discussion started by: toms
3 Replies

3. Shell Programming and Scripting

Dealing with spaces in file names in a shell script

Hi, What's the best way to find all files under a directory - including ones with space - in order to apply a command to each of them. For instance I want get a list of files under a directory and generate a checksum for each file. Here's the csh script: #!/bin/csh set files = `find $1... (5 Replies)
Discussion started by: same1290
5 Replies

4. UNIX for Dummies Questions & Answers

Unable to use mimesender to send attachments with spaces in the file names / paths

Hello, I found the mimesender multiple attachment emailing shell script in the FAQ of these forums, and I have been able to use it to send multiple files, but only if they don't have spaces in their file name or path. When I attempt to send a file with spaces in it's name, enclosed... (0 Replies)
Discussion started by: rsmorra
0 Replies

5. Shell Programming and Scripting

Remove spaces between file names

Hi All, I have spaces in between file names. "Material Header.txt" "Customer Header.txt" "Vendor Header.txt" And how can I remove spaces between file names like below MaterialHeader.txt CustomerHeader.txt VendorHeader.txt Thanks Srimitta (10 Replies)
Discussion started by: srimitta
10 Replies

6. Shell Programming and Scripting

How to strip the spaces in file names?

please somebody tell me what is wrong with this, while the thumbnail grabbing works and encoding works, but what is not working is, mv $i.jpg /var/www/thumbs/ and mv $i.mp4 /var/www/uploads/ #!/bin/bash # MINT 9 - FFMPEG - QT-FASTSTART - X264 - MP4 DIR=/var/www/tmp for i in... (9 Replies)
Discussion started by: mysoogal
9 Replies

7. UNIX for Dummies Questions & Answers

Opening a file in perl

Hi I need to open a file if a condition(for example a if a regular expression) is met. How do i do this ? open (file) if (some regex)..... (3 Replies)
Discussion started by: manutd
3 Replies

8. Shell Programming and Scripting

Remove spaces from start of file names

Hi, I have a directory with the following file names 01 - abc hyn 02-def 03-ghi.dir 04 - jhu.dir abc1 kil def bil The last two file names abc1 starts with one space and def starts with double space. I want these files in my directory to be renamed as ABC HYN DEF GHI.dir... (6 Replies)
Discussion started by: jacobs.smith
6 Replies

9. OS X (Apple)

Remove leading spaces from file names and folders

Hi All, I have a vexing issue with leading spaces in file names. Basically, we're moving tons of data from our ancient afp file share to Box.com and Box forbids leading spaces in files or folders. The HFS file system seems to be perfectly fine with this, but almost all other Unix file systems... (1 Reply)
Discussion started by: prometheon123
1 Replies

10. Shell Programming and Scripting

Finding size of files with spaces in their file names

I am running a UNIX script to get unused files and their sizes from the server. The issue is arising due to the spaces present in the filename/folder names.Due to this the du -k command doesn't work properly.But I need to calculate the size of all files including the ones which have spaces in them.... (4 Replies)
Discussion started by: INNSAV1
4 Replies
POM_XPATH_INJECT(7)						Java Packages Tools					       POM_XPATH_INJECT(7)

NAME
pom_xpath_inject - inject XML code into POM file SYNOPSIS
%pom_xpath_inject XPath [XML-code] [POM-location] DESCRIPTION
This macro patches specified POM file appending some code as childreen of all XML nodes described by the XPath expression. XPath is an expression describing a set of XML nodes in the POM file to which child code is to be appended. It must be a properly formated XPath 1.0 expression, as described in http://www.w3.org/TR/xpath/. POM location can be either a full path to the POM file, or a path to the directory containing pom.xml. If POM location is not given then pom.xml from current working directory is used. EXAMPLES
%pom_xpath_inject pom:project "<packaging>war</packaging>" - this call sets packaging of POM in current working directory to war. BUGS
POM files use a specific namespace - http://maven.apache.org/POM/4.0.0. Currently this namespace needs to be explicitly specified in all XPath POM macros by prefixing all node names with pom:. AUTHOR
Written by Mikolaj Izdebski. REPORTING BUGS
Bugs should be reported through Red Hat Bugzilla at http://bugzilla.redhat.com/. SEE ALSO
pom_add_dep(7), pom_add_parent(7), pom_add_plugin(7), pom_disable_module(7), pom_remove_dep(7), pom_remove_parent(7), pom_remove_plugin(7), pom_set_parent(7), pom_xpath_remove(7), pom_xpath_replace(7), pom_xpath_set(7). JAVAPACKAGES
06/10/2014 POM_XPATH_INJECT(7)
All times are GMT -4. The time now is 12:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy