Sponsored Content
Top Forums Shell Programming and Scripting Problem with parsing filenames containing spaces Post 302279811 by amicon007 on Saturday 24th of January 2009 12:38:15 AM
Old 01-24-2009
Problem with parsing filenames containing spaces

I tried using the following options to parse the *.sh files in a dir
(the name can contain spaces). But each of them breaks:

Code:
FILESSH=$(ls /mysh/*.sh)
 
echo "$FILESSH" | while read FILE ; do  --- do something --; done

This does not break for any whitespaces in filenames

Code:
 for FILE in $(echo $FILESSH) ; do  --- do something --; done

This breaks for any space in the name

Code:
for FILE in /mysh/*.sh ; do  --- do something --; done

Code:
echo "$FILESSH" | while IFS= read -r FILE ; do  --- do something --; done


Code 1,3,4 breaks if no sh file is found in the directory (they goes in loop once)....Code 2 does not but it breaks for any space in filename Any better ideas..??
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

spaces in filenames

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

how to handle spaces in filenames

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

spaces in filenames, for do

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

problem with spaces and argument parsing

public class HelloWorld { public static void main(String args) { System.out.println("Welcome, master"); } } and I compiled using javac HelloWorld.java ] Suppose that I execute the following command directly from the shell: java -XX:OnError="gdb - %p" HelloWorld Then it works... (8 Replies)
Discussion started by: fabulous2
8 Replies

5. Shell Programming and Scripting

spaces in filenames

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

6. UNIX for Dummies Questions & Answers

parsing filenames

How can I loose a part of the filename I want to drop the “_<Number>.sql” Below I have a listing of file names in a file Eg : CREDIT_DEL_033333.sql I want it to be CREDIT_DEL ATM_DEBIT_CARD_0999999.sql I want it to be ... (3 Replies)
Discussion started by: jville
3 Replies

7. Shell Programming and Scripting

Looping through filenames with spaces

I need to loop through the files in a directory and process the files. But some of the filenames contain spaces. Here is a little test script I've been using to experiment. (I'm not really going to call 'echo', I'm doing some other processing.) Everything I try fails. How can I do this??... (7 Replies)
Discussion started by: KenJackson
7 Replies

8. Shell Programming and Scripting

Moving filenames containing spaces

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

9. Shell Programming and Scripting

Parsing FileNames

Hi, Its been a long time since I've done any shell scripting and I need some help here. Thanks in advance... I need this as a bourne or csh script running under SCO. In a folder I have a list of Backup files named with "TarBackup plus a date and time component suffix" like this; ... (2 Replies)
Discussion started by: stanlyn
2 Replies

10. UNIX for Dummies Questions & Answers

Reading filenames with spaces

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
CUBRID_ERRNO(3) 							 1							   CUBRID_ERRNO(3)

cubrid_errno - Return the numerical value of the error message from previous CUBRID operation

SYNOPSIS
int cubrid_errno ([resource $conn_identifier]) DESCRIPTION
Returns the error number from the last CUBRID function. The cubrid_errno(3) function is used to get the error code of the error that occurred during the API execution. Usually, it gets the error code when API returns false as its return value. PARAMETERS
o $conn_identifier - The CUBRID connection identifier. If the connection identifier is not specified, the last connection opened by cubrid_connect(3) is assumed. RETURN VALUES
Returns the error number from the last CUBRID function, or 0 (zero) if no error occurred. EXAMPLES
Example #1 cubrid_errno(3) example <?php $con = cubrid_connect('localhost', 33000, 'demodb', 'dba', ''); $req = cubrid_execute($con, "select id, name from person"); if ($req) { while (list ($id, $name) = cubrid_fetch($req)) echo $id, $name; } else { echo "Error Code: ", cubrid_errno($con); echo "Error Message: ", cubrid_error($con); } ?> The above example will output: Error Code: -493 Error Message: Syntax: Unknown class "person". select id, [name] from person SEE ALSO
cubrid_error(3), cubrid_error_code(3), cubrid_error_msg(3). PHP Documentation Group CUBRID_ERRNO(3)
All times are GMT -4. The time now is 04:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy