You can simplify your loops by controlling the special IFS variable. The shell itself can be told to split on newlines and only newlines, or on commas, or quotes, or whatever.
Also, some of those echoes look redundant.
...and most of those \n's in your code aren't real newlines:
So I suspect a lot of your code isn't doing what you think it is.
Last edited by Corona688; 08-29-2019 at 02:49 PM..
I am piping STDOUT from commands such as ifconfig and dmesg through grep, sed and awk to get the information I need.
I need to now perform some looping and branching now and have been trying to figure out how to do this on the command line.
You may ask "Why the command line? - Why not put it... (2 Replies)
hi,
my first question is :-
i would like to know how do i loop through the output of a variable.
for ex:- if i have a variable called x and echo $x gives the output like
feb 19 07
feb 20 07
feb 21 07
i would like to know how do i loop through this since it is separated and i... (1 Reply)
I have a csh that is called from autosys. It fails when it hits this code
env | grep Rep
if ( $status == 0 ) then
echo ""
else
setenv REP ""
endif
However if I run it from the command line, as opposed to from autosys (job schduler) it runs fine. I thought it might be some kind of... (2 Replies)
Dear all,
I have a text file like below.
eg.txt
abcd
efgh
ijkl
mnop
I need a script, which should read the text file eg.txt and assign each line as a parameter. This , i wil use further to pass it a java command to invoke. All inside a for loop
Need your help on this.
With... (2 Replies)
I have a .csv file and i use the below while loop to navigate through it
But i need to loop from the second line since the first line is the header
How will i do it?? please help
while IFS=, read Filename Path size readonly
do
echo "Filename -> ${Filename}"
echo "Path -> ${Path}"
echo... (8 Replies)
I have been trying this program for a long time. I am trying to read a file named "odon" line by line; read the first line, send it to do a command saved in a file "perm", once the first line has finished going through the content of the file perm, the result is saved with the number of the line.... (17 Replies)
I am working with a sh script on a solaris 9 zone (sol 10 host) that grabs information to build the configuration command line. the variables Build64, SSLopt, CONFIGopt, and CC are populated in the script. the script includes
CC=`which gcc`
CONFIGopt=' --prefix=/ --exec-prefix=/usr... (8 Replies)
This works when I try to execute normally :
echo | format | nawk '/pci@1f,4000/{print x}; {x=$0 }'
But fails when define a variable and put it in a file:
cat test
c=pci@1f,4000
echo | format | nawk "/$c/{print x}; {x=$0 }"
./test
nawk: syntax error at source line 1
context is
... (6 Replies)
I am unable to expand the value of entry variable inside the nawk command.
I tried three different nawk command as below but none of them substitute the value of entry variable.
ls *.txt | while IFS='' read -r entry; do
#nawk '/<name>/{A=1;++i} A{print >> ("cmd"i"_"$entry)}... (9 Replies)
Discussion started by: mohtashims
9 Replies
LEARN ABOUT OSX
buildstrings
BuildStrings(1) BSD General Commands Manual BuildStrings(1)NAME
/usr/bin/BuildStrings -- Generate header (.h) or resource (.r) file from text files
SYNOPSIS
/usr/bin/BuildStrings [-define variable] [-header] [-attributes attributeList] [-type filekind] -id ResID -in path -out path
DESCRIPTION
The /usr/bin/BuildStrings command translates a text file into a resource or header file for use in localizing your Carbon application. The
input file is a series of newline-separated pairs of newline-separated strings. Each pair of strings represents the "base" string and the
localized equivalent. When generating a resource file, /usr/bin/BuildStrings generates a STR# resource containing only the localized equiva-
lents (which must be enclosed in double quotes in the source file). When generating the header file, /usr/bin/BuildStrings generates a C
header file with #define directives for each of the base strings (which must be valid C preprocessor symbols) equating each to the ordinal
number of the string in the STR# resource. Your C/C++ source code can use these preprocessor macros, along with standard Resource Manager
calls (like GetIndString) to load the appropriate localized string.
The source file may include #ifdef/#endif (or #ifndef/#endif) directives to conditionally include different pairs of strings, e.g. for debug-
ging builds or different versions. Note that these are the only preprocessor directives allowed in the source file.
When generating a resource file, you can set the resource ID and attributes of the STR# resource by providing /usr/bin/BuildStrings with the
appropriate command-line options.
You can use /usr/bin/BuildStrings with several different sets of strings in the same application, for example, error strings and warning
strings. The -type argument customizes some #defines in the generated header file so there are no conflicts.
The /usr/bin/BuildStrings command accepts the following arguments:
-header Generate a header file. If not provided, default is resource file format. Note that the file extension is not provided automati-
cally; your output file name must have the appropriate .h or .r extension.
-define variable
Defines variable for use in #ifdef or #ifndef conditionals. No value may be assigned to variable. This argument may be repeated
for any number of variables.
-id ResID
The resource ID for the STR# resource. There is no support for setting the resource name.
-attributes attribute
Resource attributes for the STR# resource definition (such as locked, preload, etc.) These are provided after the resource name in
the resource definition. This argument may be repeated for any number of attributes. It is ignored if generating a header.
-type filekind
Customizes three preprocessor variables (MinValidFoo, MaxValidFoo, FooRsrcID) #defined in a generated header file. Note that if
this argument is not provided, the default is the literal string "(null)", which will cause compile errors in the header file.
-in path
The input file, a set of newline-separated pairs of newline-separated strings. The first string of the pair is ignored for the
resource file (but is provided in a comment) and is used as the preprocessor symbol in the header file. The second string of the
pair is used as the resource string in the resource file and is ignored in the header file (but is provided in a comment), and must
be enclosed in double-quotes in your source file.
-out path
The output file. Note that you should provide the appropriate file extension; it is not provided automatically according to the
-header flag.
SEE ALSO Rez(1), DeRez(1)Mac OS X April 12, 2004 Mac OS X