Sponsored Content
Top Forums Shell Programming and Scripting The "read" command misinterprets file names containing spaces Post 302589030 by LessNux on Tuesday 10th of January 2012 01:53:18 PM
Old 01-10-2012
Quote:
Originally Posted by Chubler_XL
Use bash to read the into an array:
Code:
read -p "Enter files: " -a vals
 
for((i=0; i < ${#vals[@]}; i++)) do
  echo "$i: ${vals[i]}"
done



Thank you, Chubler_XL. It is a great progress that backslashes now work as I wanted. However, I still need more way to go. I would like the wildcard asterisks (*) to work. I also want quotes to work.

In other words, I would like my script to take file names (or pathnames) from the user like arguments to the "rm" command, except that my script does not take options. I would like my script to interpret backslashes, quotes, wildcard asterisks (*) and delimiting spaces in the same manner as arguments to the "rm" command.

Last edited by LessNux; 01-10-2012 at 03:01 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

passing a list of dynamic names to a "PS" command in shell script?

Hi, I am new to shell script. This is my first post .I have written a small script which returns list of names starts with "ram" in /etc/passwd .Here is that:- #!/bin/ksh NAME_LIST="name_list.txt" cat /dev/null > $NAME_LIST evalcmd="cat /etc/passwd | grep "^ram?*" | cut -d: -f1" eval... (3 Replies)
Discussion started by: sachin.tendulka
3 Replies

2. Shell Programming and Scripting

How to remove "New line characters" and "spaces" at a time

Dear friends, following is the output of a script from which I want to remove spaces and new-line characters. Example:- Line1 abcdefghijklmnopqrstuvwxyz Line2 mnopqrstuvwxyzabcdefghijkl Line3 opqrstuvwxyzabcdefdefg Here in above example, at every starting line there is a “tab” &... (4 Replies)
Discussion started by: anushree.a
4 Replies

3. Shell Programming and Scripting

script to read a line with spaces bet " " and write to a file

Hi, I need a command in UNIX KSH below is the description... MAPPING DESCRIPTION ="Test Mapping for the calid inputs" ISVALID ="YES" NAME ="m_test_xml" OBJECTVERSION ="1" VERSIONNUMBER ="1" unix ksh command to read the DESCRIPTION and write to a file Test Mapping for the calid inputs... (3 Replies)
Discussion started by: perlamohan
3 Replies

4. Shell Programming and Scripting

read -p "prompt text" foo say "read: bad option(s)" in Bourne-Shell

Hallo, i need a Prompting read in my script: read -p "Enter your command: " command But i always get this Error: -p: is not an identifier When I run these in c-shell i get this error /usr/bin/read: read: bad option(s) How can I use a Prompt in the read command? (9 Replies)
Discussion started by: wiseguy
9 Replies

5. Shell Programming and Scripting

"read" command ignoring leading spaces

I have to read a file line by line, change it and then update the file. Problem is, when i read the file, "read" command ignores leading spaces. The file is a script which is indented in many places for clarity. How to i make "read" command read leading spaces as well. (3 Replies)
Discussion started by: vickylife
3 Replies

6. Shell Programming and Scripting

Compare file names and select correct elements to include in "for each loop"

Hi everyone, I`ll try to be most clear I can explaining my help request. I have 2 folders Folder A-->This folder receives files through FTP constantly Folder B-->The files from Folder A are unzipped and then processed in Folder B Sometimes Folder A doesn`t contain all... (2 Replies)
Discussion started by: cgkmal
2 Replies

7. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

8. UNIX for Dummies Questions & Answers

Unix "look" Command "File too large" Error Message

I am trying to find lines in a text file larger than 3 Gb that start with a given string. My command looks like this: $ look "string" "/home/patrick/filename.txt" However, this gives me the following message: "look: /home/patrick/filename.txt: File too large" So, I have two... (14 Replies)
Discussion started by: shishong
14 Replies

9. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

10. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
LDAP_GET_VALUES(3)					     Library Functions Manual						LDAP_GET_VALUES(3)

NAME
ldap_get_values, ldap_get_values_len, ldap_count_values - LDAP attribute value handling routines LIBRARY
OpenLDAP LDAP (libldap, -lldap) SYNOPSIS
#include <ldap.h> char **ldap_get_values(ld, entry, attr) LDAP *ld; LDAPMessage *entry; char *attr; struct berval **ldap_get_values_len(ld, entry, attr) LDAP *ld; LDAPMessage *entry; char *attr; int ldap_count_values(vals) char **vals; int ldap_count_values_len(vals) struct berval **vals; void ldap_value_free(vals) char **vals; void ldap_value_free_len(vals) struct berval **vals; DESCRIPTION
These routines are used to retrieve and manipulate attribute values from an LDAP entry as returned by ldap_first_entry(3) or ldap_next_entry(3). ldap_get_values() takes the entry and the attribute attr whose values are desired and returns a NULL-terminated array of the attribute's values. attr may be an attribute type as returned from ldap_first_attribute(3) or ldap_next_attribute(3), or if the attribute type is known it can simply be given. The number of values in the array can be counted by calling ldap_count_values(). The array of values returned can be freed by calling ldap_value_free(). If the attribute values are binary in nature, and thus not suitable to be returned as an array of char *'s, the ldap_get_values_len() rou- tine can be used instead. It takes the same parameters as ldap_get_values(), but returns a NULL-terminated array of pointers to berval structures, each containing the length of and a pointer to a value. The number of values in the array can be counted by calling ldap_count_values_len(). The array of values returned can be freed by calling ldap_value_free_len(). ERRORS
If an error occurs in ldap_get_values() or ldap_get_values_len(), NULL is returned and the ld_errno field in the ld parameter is set to indicate the error. See ldap_error(3) for a description of possible error codes. NOTES
These routines dynamically allocate memory which the caller must free using the supplied routines. SEE ALSO
ldap(3), ldap_first_entry(3), ldap_first_attribute(3), ldap_error(3) ACKNOWLEDGEMENTS
OpenLDAP Software is developed and maintained by The OpenLDAP Project <http://www.openldap.org/>. OpenLDAP Software is derived from the University of Michigan LDAP 3.3 Release. OpenLDAP 2017/06/01 LDAP_GET_VALUES(3)
All times are GMT -4. The time now is 11:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy