Another newbie to Unix scripting Q..
How do you assign a value resulting from a command, such as awk, to a variable.
I am currently trying:-
$awk '{print $1}' file1 > variable1
with no change to $variable1.
The line:
$awk '{print $1}' file1
does print the first line of the... (3 Replies)
Hi
In my shell script, I'm trying to find the line count of a file and assign it to a variable.
LINE_COUNT=$(wc -l $FILE_NAME)
But when i display LINE_COUNT, i'm getting the linecount concatenated with the file name. I want only the number. How can i get the line count alone ? Someone... (2 Replies)
hi all,
in ksh, how do i assign the output of a find command to a variable, e.g
am trying something like this :
totalNoFiles=$(print find ./ -name "SystemOut*.log");
but when i echo $totalNoFiles it displays
find ./ -name "SystemOut*.log"
instead of the total number of... (2 Replies)
can we make a global variable and store character values and add other values to that variable ?? for example
a="hello, John"
and can we add value ". How are you? so
a can have
"hello, John. How are you?"
can someone help me?? (2 Replies)
Hi folks.
I have this variable called FirstIN that contains something like this: 001,002,003,004...
I am trying to assign the content of this variable into ModifiedIN but with the following format : 001 002 003 004...(changing the commas for spaces)
I thought about using sed but i am not... (17 Replies)
my script is some thing like this
i11="{1,2,3,4,5,6,7,8,9,10,11,}"
echo "enter value"
read value ..............suppose i11
x="$value"
echo "$($value)" .............the echo should be {1,2,3,4,5,6,7,8,9,10,11,}
but its showing "i11" only.
plz help me out to get desired... (10 Replies)
Hi
I have a script that accepts an input date in YYYY-MM-DD format.
After that, I used sed to delete the hyphen (-) which gives me an output YYYY MM DD.
My question is, how can I assign those three numbers to a three different variable.
Example:
2013-11-23 will become 2013 11 23... (4 Replies)
Unable to get the value to a variable.
set -x
cd $HOME
echo "Enter the server name"
read a
echo $a
i=4
j=1
k = ps -ef | awk '/server1/{ print $4 }' | tail -$i | head -$j`
echo $k
When I do the same in command line it works, however the same does not work when I provide that in the... (1 Reply)
I have a date column as 06302015 but I need to have variable which extracts 063015.
Am trying something like below but it is not assigning
Please let me know if am missing something. Thanks in advance.
################################
#!/usr/bin/ksh
DT=06302015
... (7 Replies)
Discussion started by: weknowd
7 Replies
LEARN ABOUT DEBIAN
mojo::util
Mojo::Util(3pm) User Contributed Perl Documentation Mojo::Util(3pm)NAME
Mojo::Util - Portable utility functions
SYNOPSIS
use Mojo::Util qw(b64_encode url_escape url_unescape);
my $string = 'test=23';
my $escaped = url_escape $string;
say url_unescape $escaped;
say b64_encode $escaped, '';
DESCRIPTION
Mojo::Util provides portable utility functions for Mojo.
FUNCTIONS
Mojo::Util implements the following functions.
"b64_decode"
my $string = b64_decode $b64;
Base64 decode string.
"b64_encode"
my $b64 = b64_encode $string;
my $b64 = b64_encode $string, "
";
Base64 encode string, the line ending defaults to a newline.
"camelize"
my $camelcase = camelize $snakecase;
Convert snake case string to camel case and replace "-" with "::".
# "FooBar"
camelize 'foo_bar';
# "FooBar::Baz"
camelize 'foo_bar-baz';
# "FooBar::Baz"
camelize 'FooBar::Baz';
"decamelize"
my $snakecase = decamelize $camelcase;
Convert camel case string to snake case and replace "::" with "-".
# "foo_bar"
decamelize 'FooBar';
# "foo_bar-baz"
decamelize 'FooBar::Baz';
# "foo_bar-baz"
decamelize 'foo_bar-baz';
"decode"
my $chars = decode 'UTF-8', $bytes;
Decode bytes to characters.
"encode"
my $bytes = encode 'UTF-8', $chars;
Encode characters to bytes.
"get_line"
my $line = get_line $string;
Extract whole line from string or return "undef". Lines are expected to end with "0x0d 0x0a" or 0x0a.
"hmac_md5_sum"
my $checksum = hmac_md5_sum $string, 'passw0rd';
Generate HMAC-MD5 checksum for string.
"hmac_sha1_sum"
my $checksum = hmac_sha1_sum $string, 'passw0rd';
Generate HMAC-SHA1 checksum for string.
"html_escape"
my $escaped = html_escape $string;
my $escaped = html_escape $string, '^
!#$%(-;=?-~';
Escape unsafe characters in string with HTML5 entities, the pattern used defaults to "^
!#$%(-;=?-~".
"html_unescape"
my $string = html_unescape $escaped;
Unescape all HTML5 entities in string.
"md5_bytes"
my $checksum = md5_bytes $string;
Generate binary MD5 checksum for string.
"md5_sum"
my $checksum = md5_sum $string;
Generate MD5 checksum for string.
"punycode_decode"
my $string = punycode_decode $punycode;
Punycode decode string.
"punycode_encode"
my $punycode = punycode_encode $string;
Punycode encode string.
"quote"
my $quoted = quote $string;
Quote string.
"qp_decode"
my $string = qp_decode $qp;
Quoted Printable decode string.
"qp_encode"
my $qp = qp_encode $string;
Quoted Printable encode string.
"secure_compare"
my $success = secure_compare $string1, $string2;
Constant time comparison algorithm to prevent timing attacks.
"sha1_bytes"
my $checksum = sha1_bytes $string;
Generate binary SHA1 checksum for string.
"sha1_sum"
my $checksum = sha1_sum $string;
Generate SHA1 checksum for string.
"trim"
my $trimmed = trim $string;
Trim whitespace characters from both ends of string.
"unquote"
my $string = unquote $quoted;
Unquote string.
"url_escape"
my $escaped = url_escape $string;
my $escaped = url_escape $string, '^A-Za-z0-9-._~';
Percent-encode unsafe characters in string, the pattern used defaults to "^A-Za-z0-9-._~".
"url_unescape"
my $string = url_unescape $escaped;
Decode percent-encoded characters in string.
"xml_escape"
my $escaped = xml_escape $string;
Escape only the characters "&", "<", ">", """ and "'" in string, this is a much faster version of "html_escape".
SEE ALSO
Mojolicious, Mojolicious::Guides, <http://mojolicio.us>.
perl v5.14.2 2012-09-05 Mojo::Util(3pm)