Sponsored Content
Top Forums Shell Programming and Scripting Ls command in a for loop displaying error Post 303028751 by rbatte1 on Monday 14th of January 2019 07:49:01 AM
Old 01-14-2019
Do you risk having spaces, tab or other naughty characters in the directory name or file name? You would be safer to use "${3}/${file}" to ensure that the values are treated as a single item. if you have a for loop on items with spaces, then they will be split up and processed separately. For instance:-
Code:
whole_message="Hello world"
for one_message in ${whole_message}
do
   echo ${one_message}
done
Hello                                          # <---- Output split to one
world.                                         # <---- line for word

whole_message="Hello world"
for one_message in "${whole_message}"          # <--- Wrapped in double quotes
do
   echo ${one_message}
done
Hello world                                    # <---- Output for one value all written as one line.


I hope that this helps,
Robin
This User Gave Thanks to rbatte1 For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Displaying what a command is doing/has done

I would like to see what a command is doing. For example, say I move 10 files using mv * somedir. Can I use some other command to see a verification of each files movement. Like: file1 moved to somedir file2 moved to somedir ... but, i'd to have this capability for all commands. it seems... (1 Reply)
Discussion started by: quantumechanix
1 Replies

2. Shell Programming and Scripting

displaying the path in the command line

Hi all, Does anyone know how to ammend the .cshrc file in $HOME for your session to display the path as part of the command line? So that I dont need to keep on typing pwd to see where I am? thanks Ocelot (2 Replies)
Discussion started by: ocelot
2 Replies

3. Shell Programming and Scripting

Displaying list of backup files using for loop

Hi, I want to display list of last 10 backup files (with numbering) from the temporary file c:/tmp/tmp_list_bkp.txt Example : 1) backup_file1 2) backup_file2 3) backup_file3 ........ ........ I tried as below but not working. for file in c:/tmp/tmp_list_bkp.txt do echo... (3 Replies)
Discussion started by: milink
3 Replies

4. UNIX for Dummies Questions & Answers

Trouble displaying parameters passed into a for loop

#!/bin/bash function check_num_args() { if ; then echo "Please provide a file name" else treat_as_file $* fi } function treat_as_file() { numFiles=$# for((i=1;i<=$numFiles;i++));do echo $i ... (3 Replies)
Discussion started by: kikilahooch
3 Replies

5. Shell Programming and Scripting

while loop error. (command not found)

can any1 please tell me what is problem with following code: i=1; cat test| while read CMD; do Var$i=$CMD; or Var$i=$(echo $CMD) ; let i++ doneI keep getting error : line 4: Var1=sometext: command not found (2 Replies)
Discussion started by: kashif.live
2 Replies

6. Shell Programming and Scripting

for loop with internal unix command in statement throwing error

Hi I've gotten a plugin script that won't run. I keeps throwing an error at the following line. for BARCODE_LINE in `cat ${TSP_FILEPATH_BARCODE_TXT} | grep "^barcode"` do #something done The error reads ... (3 Replies)
Discussion started by: jdilts
3 Replies

7. Shell Programming and Scripting

[Solved] While loop error when add sqlplus command

Hi gurus, I hit a block when write the script. I need do while loop, in the loop I have code below. sqlplus -s abc/abc@abc <<EOF spool testwhile select * from dual; spool off exit; EOF when I run script with only this code, it works fine. if I add code as below: #!/bin/ksh ... (5 Replies)
Discussion started by: ken6503
5 Replies

8. Red Hat

Displaying command return in one line

Hello all I have a query (SQL) that returns a rather long field from an Oracle database. The field in question is defined on 400 characters but all these 400 cannot be displayed by the echo command. Thus when I launch the following command: echo "SELECT FIELD01 FROM TABLE_NAME;" | sqlplus -s... (9 Replies)
Discussion started by: S. BASU
9 Replies

9. Shell Programming and Scripting

Problem while displaying(cat) file content inside telnet loop .

Hi Team, Not getting the file output inside my email which i am sending from unix box. . Please refer the below code : #!/bin/sh { sleep 5 echo ehlo 10.56.185.13 sleep 3 echo mail from: oraairtel@CNDBMUREAPZP02.localdomain sleep 3 echo rcpt to: saurabhtripathi@anniksystems.com... (1 Reply)
Discussion started by: tripathi1990
1 Replies

10. UNIX for Beginners Questions & Answers

Displaying multiple variables in for loop

Hi! I've run into a problem where my variables are displayed in the wrong order. Basically I'm supposed to use a file that has information like this username:firstname:lastname:etc:etc. What I'm interested in doing is reformating it into a something more like this: username lastname,... (2 Replies)
Discussion started by: reindeermountai
2 Replies
gencat(1)						      General Commands Manual							 gencat(1)

NAME
gencat - generate a formatted message catalog file SYNOPSIS
catfile msgfile ... DESCRIPTION
Message catalogs allow a program to process input and produce output according to local customs and languages. For details, see The command merges each message source msgfile into a formatted message catalog catfile that can be accessed by (see catgets(3C)). If cat- file does not exist, it is created. If catfile exists, its messages are included in the new catfile. If set and message numbers collide, the new message text in file replaces the old message text in catfile. A msgfile consists of message, directive, and comment lines (all without leading spaces or tabs) described below. Except as noted, fields are separated by one or more space or tab characters. If is specified as catalog file, standard output is used. If is specified for an instance of message file, standard input is used. A directive specifies the set s, of the messages that follow until the next or end-of-file appears. The set number s is an unsigned integer in the range 1 through Any string following the set number is treated as a comment. If a directive is not specified, messages are put in the default set Set numbers must be in ascending order within a msgfile but need not be contiguous. A directive deletes the message set identified by the set number s, from an existing message catalog. Any string following the set number is treated as a comment. m message_text A message line specifies a message number m, and associated message text. The message number m is an unsigned integer in the range 1 through The message_text is a C string, including spaces, tabs and (back- slash) escapes, but by default without surrounding quotes (see directive below). The message number m is separated from the message_text by a single space or tab character. The message_text begins with the first character following the separator and ends at new-line. Extra spaces or tabs (including any trailing spaces or tabs) are considered part of the message_text. The message_text of a message line is stored in catfile with message number m and set number s specified by the most recent directive. Message numbers must be in ascending order within a set, but need not be contiguous. Note that the space or tab separator distinguishes insertion of a null message from deletion of a message. If a message line has a number and separator but no text, the message number and an associated null message string are stored in catfile. If a message line has a number but neither separator nor text, the message number and its associated message text are deleted from catfile. If the option is specified, the length of message_text must be no more than - 1 bytes. If the option is not speci- fied, the length of message_text must be no more than bytes. See catgets(3C), for message length limits imposed by these routines. A directive specifies a quote character q, used to surround message_text and make leading and trailing space visible in a message line. Any string following the specified quote character q is treated as a comment. By default, or if a quote character q not is supplied, quoting of message_text is not recognized. A followed by a space or tab is treated as a comment and can appear anywhere in a file. A line consisting of zero or more spaces or tabs is treated as a comment line. and are defined in is defined in is defined in EXTERNAL INFLUENCES
Environment Variables provides a default value for the internationalization variables that are unset or null. If is unset or null, the default value of "C" (see lang(5)) is used. If any of the internationalization variables contains an invalid setting, will behave as if all internationalization variables are set to "C". See environ(5). if set to a non-empty string value, overrides the values of all of the other internationalization variables. determines the interpretation of text as single and/or multi-byte characters, the classification of characters as printable, and the char- acters matched by character class expressions in regular expressions. determines the locale that should be used to affect the format and contents of diagnostic messages written to standard error and informa- tive messages written to standard output. determines the location of message catalogs for the processing of International Code Set Support Single- and multi-byte character code sets are supported. WARNINGS
The directive is not currently supported on the HP MPE and RTE operating systems. AUTHOR
was developed by HP and the X/Open Company, Ltd. SEE ALSO
dumpmsg(1), findmsg(1), insertmsg(1), catgets(3C), catopen(3C). STANDARDS CONFORMANCE
gencat(1)
All times are GMT -4. The time now is 12:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy