Sponsored Content
Top Forums Shell Programming and Scripting Sorting the contents of a variable Post 303035002 by RudiC on Friday 10th of May 2019 04:42:36 PM
Old 05-10-2019
How about
Code:
$ echo $(shuf -e ${OPTIONS,,} | sort -u)
 a b c d

(provided your system's bash provides "Parameter Expansion / Case modification" and shuf has the -e option)


EDIT: or

Code:
$ echo $( xargs -n1 -d" " <<< ${OPTIONS,,} | sort -u)
 a b c d


or, of course,

Code:
$ echo $( tr ' ' '\n' <<< ${OPTIONS,,} | sort -u)


Last edited by RudiC; 05-10-2019 at 06:27 PM..
This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

adding contents of a variable to a command

hi all, i'm new to shell scripting, so i'm not sure how to work this. Is it possible to read in the contents of a variable and add it to a command? for example: ------------------------ #!/bin/sh set example = -dfr rm ${example} ------------------------ when i run the script, i want... (2 Replies)
Discussion started by: gammarays
2 Replies

2. UNIX for Dummies Questions & Answers

Save contents of a Variable

I want to save the contents of a variable to a file. How can that be achieved? I have tried with: echo $varname > textfile.txt but for some reason it does not print anything. (1 Reply)
Discussion started by: carl_vieyra
1 Replies

3. Shell Programming and Scripting

unique sort contents of a variable

Hi , I have #echo $var1 #hdisk2 hdisk3 hdisk0 hdisk2 Now I need to remove duplicate entries from this . ie. after sorting it should only have hdisk2 hdisk3 hdisk0 . I can have these values in a array as well . I understand we can use sort -u to remove the duplicates in a... (2 Replies)
Discussion started by: praveenbvarrier
2 Replies

4. Shell Programming and Scripting

Storing the contents of a file in a variable

There is a file named file.txt whose contents are: +-----------------------------------+-----------+ | Variable_name | Value | +-----------------------------------+-----------+ | Aborted_clients | 0 | | Aborted_connects | 25683... (6 Replies)
Discussion started by: proactiveaditya
6 Replies

5. Shell Programming and Scripting

how to grep the contents of a variable..

Hello All, I've written a script to collect all audit logs files; now i want to see only the files from it which contains certain x tablenames. I've stored all the tablenames in a log file and using it through variable in a script (ex:below) $ more tablenames.log (this is just a samle... (2 Replies)
Discussion started by: suri.tyson
2 Replies

6. Shell Programming and Scripting

How to read contents of a file into variable :(

My file is in this format : username : student information : default shell : student ID Eg : joeb:Joe Bennett:/bin/csh:1234 jerryd:Jerry Daniels:/bin/csh:2345 deaverm: Deaver Michelle:/bin/bash:4356 joseyg:Josey Guerra:/bin/bash:8767 michaelh:Michael Hall:/bin/ksh:1547 I have to... (1 Reply)
Discussion started by: dude_me5
1 Replies

7. Homework & Coursework Questions

How to read contents of a file into variable :(

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I have to read the contents of each field of a file creating user accounts. The file will be of format : ... (6 Replies)
Discussion started by: dude_me5
6 Replies

8. Shell Programming and Scripting

Providing variable contents to awk

Hello, All. This is my first post here, and I expect that the answer is simple, but I can't find it. Might be the way I'm searching. I'm fairly new to Unix/Linux, and I'm writing a Korn Shell Script. I am trying to provide a value that is already in a variable to awk so that awk can pull out the... (3 Replies)
Discussion started by: compguy74
3 Replies

9. Shell Programming and Scripting

Folder contents getting appended as strings while redirecting file contents to a variable

Hi one of the output of the command is as below # sed -n "/CCM-ResourceHealthCheck:/,/---------/{/CCM-ResourceHealthCheck:/d;/---------/d;p;}" Automation.OutputZ$zoneCounter | sed 's/$/<br>/' Resource List : <br> *************************** 1. row ***************************<br> ... (2 Replies)
Discussion started by: vivek d r
2 Replies

10. UNIX for Beginners Questions & Answers

Storing file contents to a variable

Hi All, I was trying a shell script. I was unable to store file contents to a variable in the script. I have tried the below but unable to do it. Input = `cat /path/op.diary` Input = $(<op.diary) I am using ksh shell. I want to store the 'op.diary' file contents to the variable 'Input'... (12 Replies)
Discussion started by: am24
12 Replies
Locale::Codes::LangFam(3)				User Contributed Perl Documentation				 Locale::Codes::LangFam(3)

NAME
Locale::Codes::LangFam - standard codes for language extension identification SYNOPSIS
use Locale::Codes::LangFam; $lext = code2langfam('apa'); # $lext gets 'Apache languages' $code = langfam2code('Apache languages'); # $code gets 'apa' @codes = all_langfam_codes(); @names = all_langfam_names(); DESCRIPTION
The "Locale::Codes::LangFam" module provides access to standard codes used for identifying language families, such as those as defined in ISO 639-5. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default ISO 639-5 language family codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying language families. A code set may be specified using either a name, or a constant that is automatically exported by this module. For example, the two are equivalent: $lext = code2langfam('apa','alpha'); $lext = code2langfam('apa',LOCALE_LANGFAM_ALPHA); The codesets currently supported are: alpha This is the set of three-letter (lowercase) codes from ISO 639-5 such as 'apa' for Apache languages. This is the default code set. ROUTINES
code2langfam ( CODE [,CODESET] ) langfam2code ( NAME [,CODESET] ) langfam_code2code ( CODE ,CODESET ,CODESET2 ) all_langfam_codes ( [CODESET] ) all_langfam_names ( [CODESET] ) Locale::Codes::LangFam::rename_langfam ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangFam::add_langfam ( CODE ,NAME [,CODESET] ) Locale::Codes::LangFam::delete_langfam ( CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_alias ( NAME ,NEW_NAME ) Locale::Codes::LangFam::delete_langfam_alias ( NAME ) Locale::Codes::LangFam::rename_langfam_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::delete_langfam_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes::API man page. SEE ALSO
Locale::Codes The Locale-Codes distribution. Locale::Codes::API The list of functions supported by this module. http://www.loc.gov/standards/iso639-5/id.php ISO 639-5 . AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 2011-2013 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.16.3 2013-02-27 Locale::Codes::LangFam(3)
All times are GMT -4. The time now is 08:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy