01-21-2013
Extract a string from another string in UNIX
I have a string
string="Please have a nice day and sleep well Replace_12123_31233_32134_12342 Good day"
How do i replace "Replace_12123_31233_32134_1234" in the above string.??
Please help.
Regards,
Qwerty
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
How to extract a portion of a string from a full string using unix.
For example:
Say source string is = "req92374923.log"
I want only the numeric portion of the string say "92374923" how to do that in Unix. (2 Replies)
Discussion started by: ds_sastry
2 Replies
2. Shell Programming and Scripting
Hi, guys. I have one question:
I need to search for a string in a file, and then extract another string from the file and assign it to a variable.
For example:
the contents of the file (group) is below:
...
ftp:x:23:
mail:x:34
...
testing:x:2001
sales:x:2002
development:x:2003
...... (6 Replies)
Discussion started by: daikeyang
6 Replies
3. Shell Programming and Scripting
Hi all,
i have such string stored in a variable
var1 = 00000120
i want the o/p
var1 = 120
is it possible to have such o/p in ksh/bash ...
thanx in advance for the help
sonu (3 Replies)
Discussion started by: sonu_pal
3 Replies
4. Shell Programming and Scripting
continuing from my previous post, whose link is given below as a reference
https://www.unix.com/shell-programming-scripting/171076-shell-scripting.html#post302573569
consider there is create table commands in a file for eg:
CREATE TABLE `Blahblahblah` (
`id` int(11) NOT NULL... (2 Replies)
Discussion started by: vivek d r
2 Replies
5. Shell Programming and Scripting
Hi,
May i ask if someone share some command for extracting a string between 2 ref string in a txt file
My objective: i had a file with multiple lines and wants only to extract the string "watch?v=IbkAXOmEHpY" or "watch?v=<11 random character>", when i used "grep 'watch?=*' i got a results per... (4 Replies)
Discussion started by: jao_madn
4 Replies
6. Shell Programming and Scripting
Thank you (2 Replies)
Discussion started by: Pratik Majithia
2 Replies
7. Shell Programming and Scripting
Need Assistance in shell programming... I have a huge file which has multiple stations and i wanted to search particular station and extract few lines from it and the rest is not needed
Bold letters are the stations . The whole file has multiple stations .
Below example i wanted to search... (4 Replies)
Discussion started by: ajayram_arya
4 Replies
8. Shell Programming and Scripting
Hi Team
I have an huge xml where i need to search for a ceratin numbers. For example
2014-05-06 15:15:41,498 INFO WebContainer : 10 CommonServicesLogs - CleansingTriggerService.invokeCleansingService Entered PUBSUB NOTIFY MESSAGE () -
<?xml version="1.0" encoding="UTF-8"... (5 Replies)
Discussion started by: Kannannair
5 Replies
9. Shell Programming and Scripting
Hello guys,
I have problem with hpux shell script. I have one big text file that contains like
SOH
bla bla bla
bla bla bla
ETX SOH
bla bla bla
ETX
SOH
bla bla bla
ETX
What I need to do is save first SOH*BLA into file1.txt, save second SOH*BLA into file2.txt and so on.... (17 Replies)
Discussion started by: sembii
17 Replies
10. Shell Programming and Scripting
How can I extract digits at the end of a string in UNIX shell scripting or perl?
cat file.txt
abc_d123_4567.txt
A246_B789.txt
B123cc099.txt
a123_B234-012.txt
a13.txt
What can I do here? Many thanks.
cat file.txt | sed "s/.txt$//" | ........
4567
789
099
012
13 (11 Replies)
Discussion started by: mingch
11 Replies
LEARN ABOUT REDHAT
nl_langinfo
NL_LANGINFO(3) Linux Programmer's Manual NL_LANGINFO(3)
NAME
nl_langinfo - query language and locale information
SYNOPSIS
#include <langinfo.h>
char *nl_langinfo(nl_item *item);
DESCRIPTION
The nl_langinfo function provides access to locale information in a more flexible way than localeconv(3) does. Individual and additional
elements of the locale categories can be queried.
Examples for the locale elements that can be specified in item using the constants defined in <langinfo.h> are:
CODESET (LC_CTYPE)
Return a string with the name of the character encoding used in the selected locale, such as "UTF-8", "ISO-8859-1", or
"ANSI_X3.4-1968" (better known as US-ASCII). This is the same string that you get with "locale charmap". For a list of character
encoding names, try "locale -m", cf. locale(1).
D_T_FMT (LC_TIME)
Return a string that can be used as a format string for strftime(3) to represent time and date in a locale-specific way.
D_FMT (LC_TIME)
Return a string that can be used as a format string for strftime(3) to represent a date in a locale-specific way.
T_FMT (LC_TIME)
Return a string that can be used as a format string for strftime(3) to represent a time in a locale-specific way.
DAY_{1-7} (LC_TIME)
Return name of the n-th day of the week. [Warning: this follows the US convention DAY_1 = Sunday, not the international convention
(ISO 8601) that Monday is the first day of the week.]
ABDAY_{1-7} (LC_TIME)
Return abbreviated name of the n-th day of the week.
MON_{1-12} (LC_TIME)
Return name of the n-th month.
ABMON_{1-12} (LC_TIME)
Return abbreviated name of the n-th month.
RADIXCHAR (LC_NUMERIC)
Return radix character (decimal dot, decimal comma, etc.).
THOUSEP (LC_NUMERIC)
Return separator character for thousands (groups of three digits).
YESEXPR (LC_MESSAGES)
Return a regular expression that can be used with the regex(3) function to recognize a positive response to a yes/no question.
NOEXPR (LC_MESSAGES)
Return a regular expression that can be used with the regex(3) function to recognize a negative response to a yes/no question.
CRNCYSTR (LC_MONETARY)
Return the currency symbol, preceded by "-" if the symbol should appear before the value, "+" if the symbol should appear after the
value, or "." if the symbol should replace the radix character.
The above list covers just some examples of items that can be requested. For a more detailed list, please consult The GNU C Library Refer-
ence Manual.
RETURN VALUE
If no locale has been selected for the appropriate category, nl_langinfo returns a pointer to the corresponding string in the "C" locale.
If item is not valid, a pointer to an empty string is returned.
This pointer may point to static data that may be overwritten on the next call to nl_langinfo or setlocale.
CONFORMING TO
The Single UNIX(R) Specification, Version 2
SEE ALSO
localeconv(3), setlocale(3), locale(1), locale(7), charsets(7), The GNU C Library Reference Manual
GNU
2001-05-11 NL_LANGINFO(3)