Sponsored Content
Top Forums UNIX for Dummies Questions & Answers outputting selected characters from within a variable Post 302361880 by skinnygav on Wednesday 14th of October 2009 09:31:12 AM
Old 10-14-2009
ok now have

Code:
echo $var1 | eval awk -F \"\" \'{print \$$var2}\'

which works fine, thanks for all your help guys!

---------- Post updated at 08:31 AM ---------- Previous update was at 08:29 AM ----------

oh thanks dr house, i'll have a look at that syntax as it means I will b able to echo -n so that all characters are output to the same line.

does print within awk have a similar option?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

To get the characters from a variable

Hi , I need to get the specified word from the variable.can some one help me out in this ? input=ASD34567P i need to get the value as : output1=34567 So i need to ignore the last character and get the remaining values. THANKS IN ADVANCE. (6 Replies)
Discussion started by: ithirak17
6 Replies

2. UNIX for Dummies Questions & Answers

Perl - converting selected characters to upper/lower case

Using STDIN, how can I use perl to take an input string, with all lower case letters in the first five characters, and convert them to uppercase... then take all uppercase letters in the second five characters and convert them to lowercase. Example: MichaelSmith to michaELSMIth Thank you! (2 Replies)
Discussion started by: doubleminus
2 Replies

3. Shell Programming and Scripting

how to assign to each variable after selected?

Hi Everyone, I need to assign the value to the variable after selection. Anyone can help me? for example: data_type_SQL=$($CONNECT cat <<-__EOF__ SET NOCOUNT ON select location_type, location_id, warehouse from JEALOCATION where LOCATION_ID="$data_LocID_SQL" for "data_type_SQL"... (9 Replies)
Discussion started by: ryanW
9 Replies

4. Shell Programming and Scripting

Cutting characters in a variable

I have a variable var which contains "ABCDEFDH" Now I have to remove the first 4 characters that is "ABCD" so my variable should contain only "DEFH" plzz tell me how to do that . i am using bash shell (1 Reply)
Discussion started by: cynosure2009
1 Replies

5. Shell Programming and Scripting

trying to print selected fields of selected lines by AWK

I am trying to print 1st, 2nd, 13th and 14th fields of a file of line numbers from 29 to 10029. I dont know how to put this in one code. Currently I am removing the selected lines by awk 'NR==29,NR==10029' File1 > File2 and then doing awk '{print $1, $2, $13, $14}' File2 > File3 Can... (3 Replies)
Discussion started by: ananyob
3 Replies

6. Shell Programming and Scripting

Stripping characters from a variable

I'm using a shell script to get user input with this command: read UserInput I would then like to take the "UserInput" variable and strip out all of the following characters, regardless of where they appear in the variable or how many occurrences there are: \/":|<>+=;,?*@ I'm not sure... (5 Replies)
Discussion started by: nrogers64
5 Replies

7. Shell Programming and Scripting

getting first two characters of variable

From a shell script, I'm trying to get the first two characters of an environment variable. If I type at the command promot: XX=`echo $MYVAR | cut -c1-2` echo $XX It works just fine However, if I execute the exact same thing from a shell script, I get: cut: you must specify a list of... (2 Replies)
Discussion started by: Boomn4x4
2 Replies

8. Shell Programming and Scripting

Bash string variable outputting incorrectly

Hello All, I am learning BASH scripting and I would appreciate any help with a small problem I am having... I am writing a script that builds a simple hosts file for DNS reasons related to a piece of software called netdb by parsing another application's config files for IP's and their... (4 Replies)
Discussion started by: Wesley545
4 Replies

9. Shell Programming and Scripting

Get first four characters from the variable name

Hi all I have a variable name as below runbatch=FCSTworLOADfx_CYR Now i need to search for FCST in this variable and run a program I am doing like this but it is failing if ; then ****RUN PROGRAM** Please help DJ Please use CODE tags when displaying sample input,... (3 Replies)
Discussion started by: Hypesslearner
3 Replies

10. Shell Programming and Scripting

Outputting characters after a given string and reporting the characters in the row below --sed

I have this fastq file: @M04961:22:000000000-B5VGJ:1:1101:9280:7106 1:N:0:86 GGGGGGGGGGGGCATGAAAACATACAAACCGTCTTTCCAGAAATTGTTCCAAGTATCGGCAACAGCTTTATCAATACCATGAAAAATATCAACCACACCA +test-1 GGGGGGGGGGGGGGGGGCCGGGGGFF,EDFFGEDFG,@DGGCGGEGGG7DCGGGF68CGFFFGGGG@CGDGFFDFEFEFF:30CGAFFDFEFF8CAF;;8... (10 Replies)
Discussion started by: Xterra
10 Replies
GET_CLASS_VARS(3)							 1							 GET_CLASS_VARS(3)

get_class_vars - Get the default properties of the class

SYNOPSIS
array get_class_vars (string $class_name) DESCRIPTION
Get the default properties of the given class. PARAMETERS
o $class_name - The class name RETURN VALUES
Returns an associative array of declared properties visible from the current scope, with their default value. The resulting array elements are in the form of varname => value. In case of an error, it returns FALSE. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.0.3 | | | | | | | get_class_vars(3) will only return the properties | | | that can be accessed from the current scope. | | | | | 5.0.2 | | | | | | | Calling get_class_vars(3) will now expose all | | | the properties as an array, unlike previous be- | | | haviour where protected and private properties | | | were prefixed with nul bytes. | | | | | 5.0.1 | | | | | | | Calling get_class_vars(3) will expose all prop- | | | erties, as when converting an object to a class. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 get_class_vars(3) example <?php class myclass { var $var1; // this has no default value... var $var2 = "xyz"; var $var3 = 100; private $var4; // constructor function myclass() { // change some properties $this->var1 = "foo"; $this->var2 = "bar"; return true; } } $my_class = new myclass(); $class_vars = get_class_vars(get_class($my_class)); foreach ($class_vars as $name => $value) { echo "$name : $value "; } ?> The above example will output: var1 : var2 : xyz var3 : 100 Example #2 get_class_vars(3) and scoping behaviour <?php function format($array) { return implode('|', array_keys($array)) . " "; } class TestCase { public $a = 1; protected $b = 2; private $c = 3; public static function expose() { echo format(get_class_vars(__CLASS__)); } } TestCase::expose(); echo format(get_class_vars('TestCase')); ?> The above example will output: // 5.0.0 a| * b| TestCase c a| * b| TestCase c // 5.0.1 - 5.0.2 a|b|c a|b|c // 5.0.3 + a|b|c a SEE ALSO
get_class_methods(3), get_object_vars(3). PHP Documentation Group GET_CLASS_VARS(3)
All times are GMT -4. The time now is 05:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy