Sponsored Content
Full Discussion: Unix filenames and spaces
Top Forums Shell Programming and Scripting Unix filenames and spaces Post 302105263 by reborg on Wednesday 31st of January 2007 06:07:41 PM
Old 01-31-2007
Code:
while read line ; do
   ls -l "$file"
done < test

 

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

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

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

6. Shell Programming and Scripting

awk and spaces in filenames

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

removing spaces in filenames

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

Remove spaces in filenames

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

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

10. Shell Programming and Scripting

Handling filenames with spaces

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
EXAMPLES-WITH-PDO_4D(3) 						 1						   EXAMPLES-WITH-PDO_4D(3)

Examples with PDO_4D - Examples PDO_4D

	This basic example show how to connect, execute a query, read data and disconnect from a 4D SQL server.

       Example #1

	      Basic example with PDO_4D

	      <?php
	      $dsn = '4D:host=localhost;charset=UTF-8';
	      $user = 'test';
	      $pass = 'test';

	      // Connection to the 4D SQL server
	      $db = new PDO($dsn, $user, $pass);

	      try {
		  $db->exec('CREATE TABLE test(id varCHAR(1) NOT NULL, val VARCHAR(10))');
	      } catch (PDOException $e) {
		  die("Erreur 4D : " . $e->getMessage());
	      }

	      $db->exec("INSERT INTO test VALUES('A', 'B')");
	      $db->exec("INSERT INTO test VALUES('C', 'D')");
	      $db->exec("INSERT INTO test VALUES('E', 'F')");

	      $stmt = $db->prepare('SELECT id, val from test');

	      $stmt->execute();
	      print_r($stmt->fetchAll());

	      unset($stmt);
	      unset($db);
	      ?>

	      The above example will output:

	      Array
	      (
		  [0] => Array
		      (
			  [ID] => A
			  [0] => A
			  [VAL] => B
			  [1] => B
		      )

		  [1] => Array
		      (
			  [ID] => C
			  [0] => C
			  [VAL] => D
			  [1] => D
		      )

		  [2] => Array
		      (
			  [ID] => E
			  [0] => E
			  [VAL] => F
			  [1] => F
		      )

	      )

	This example shows how to execute a query in 4D language, and how to read the result through PDO_4D.

       Example #2

	      Accessing 4D language from pdo_4d

	       Set  up a 4D method, called method. Make sure in the method properties that the option Available via SQL is checked. The 4D code is
	      the following.

	      C_TEXTE($0)
	      $0:=Version application(*);

	       The PHP code to use the above 4D method is :

	      <?php
	      $dsn = '4D:host=localhost;charset=UTF-8';
	      $user = 'test';
	      $pass = 'test';

	      // Connection to the 4D server
	      $db = new PDO($dsn, $user, $pass);

	      $stmt = $db->prepare('SELECT {FN method() AS VARCHAR } FROM _USER_SCHEMAS LIMIT 1');

	      $stmt->execute();
	      print_r($stmt->fetchAll());

	      unset($stmt);
	      unset($db);
	      ?>

	      The above example will output:

	      (
		  [0] => Array
		      (
			  [<expression>] => F0011140
			  [0] => F0011140
		      )

	      )

       Example #3

	      Escaping 4D table names

	       This examples illustrates how to escape characters in a 4D SQL query.

	      <?php
	      $dsn = '4D:host=localhost;charset=UTF-8';
	      $user = 'test';
	      $pass = 'test';

	      // Connection to 4D server 4D
	      $db = new PDO($dsn, $user, $pass);

	      $objects = array('[',']','[]','][','[[',']]','[[[',']]]','TBL ]]32[23');

	      foreach($objects as $id => $object) {
		  $object = str_replace(']',']]', $object);
		  print "$object
";

		  $db->exec('CREATE TABLE IF NOT EXISTS ['.$object.'](['.$object.'] FLOAT)');

		  $req = "INSERT INTO [$object] ([$object]) VALUES ($id);";
		  $db->query($req);

		  $q = $db->prepare("SELECT [$object] FROM [$object]");
		  $q->execute();
		  $x[] = $q->fetch(PDO::FETCH_NUM);

		  $db->exec('DROP TABLE ['.$object.'];');
	      }

	      ?>

	      The above example will output:

	      [
	      ]]
	      []]
	      ]][
	      [[
	      ]]]]
	      [[[
	      ]]]]]]
	      TBL ]]]]32[23

PHP Documentation Group 												   EXAMPLES-WITH-PDO_4D(3)
All times are GMT -4. The time now is 02:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy