Although this works fine for the given example, it would be safer to use:
in case $value sometimes expands to a string containing whitespace characters.
These 2 Users Gave Thanks to Don Cragun For This Post:
Hi All;
Having a problem with a file..
the file contains the following data... (a snapshot)
1331F9E9DB7C2BB80EAEDE3A8F043B94,AL7 1DZ,M,50
186FDF93E1303DBA217279EC3671EA91,NG5 1JU,M,24
3783FFAF602015056A8CD21104B1AAAF,CH42 4NQ,M,17
It has 3 columns sepreated by a ,
the second column... (7 Replies)
I am coding a C program to read a plain text file. There are a lot of blank fields or a string with white spaces. I want to know is there such a function called trim() in C to clean the white space around a string? Or some other way can do this efficiently? Thanks. (18 Replies)
Dear Members,
Suppose i have a variable test which stores a string as below:
test='John drives+++++++++a+++++car'
now i want to use sed on the above variable and replace + with a white space, so that i get
echo $test should give me
'john drives a car'
Between... (1 Reply)
Im trying to add 5 blank spaces to the end of each line in a file in a sed script. I can figure out who o put the spaces pretty much anywhere else but at the end.
thanks
Karl (7 Replies)
Hi,
What sed command (if sed is the right command) can remove ALL white space from my file. I have a csv, except I want to remove all white space between commas and characters.
My idea (without testing)
sed 's/ //g'
Is there a better way? (18 Replies)
Suppose, I have a variable var=" name is ".
I want to remove the blank spaces from the begining and endonly, not from the entire string.
So, that the variable/string looks like following
var="name is".
Please look after the issue. (3 Replies)
I need to read in the string from input file and reform it by cut each segment and check the last segement lenght. If the last segment length is not as expected (see below segment file or table. It is predefined), then pad enough space.
Old string
FU22222222CA6666666666AKxvbFMddreeadBP999... (1 Reply)
I need to read in the string from input file and reform it by cut each segment and check the last segement lenght. If the last segment length is not as expected (see below segment file or table. It is predefined), then pad enough space.
Old string
FU22222222CA6666666666AKxvbFMddreeadBP999... (11 Replies)
Hi,
I am trying to remove lines once a string is found till another string is found including the start string and end string. I want to basically grab all the lines starting with color (closing bracket). PS: The line after the closing bracket for color could be anything (currently 'more').... (1 Reply)
hi guys
how can i add spacein file name with sed if strings have no space around dash
input
19-20
( 18-19 )
ABC-EFG
output after add white space
19 - 20
(18 - 19 )
ABC - EFG
thx in advance (2 Replies)
Discussion started by: mhs
2 Replies
LEARN ABOUT MOJAVE
iconv
ICONV(1) Linux Programmer's Manual ICONV(1)NAME
iconv - character set conversion
SYNOPSIS
iconv [OPTION...] [-f encoding] [-t encoding] [inputfile ...]
iconv -l
DESCRIPTION
The iconv program converts text from one encoding to another encoding. More precisely, it converts from the encoding given for the -f
option to the encoding given for the -t option. Either of these encodings defaults to the encoding of the current locale. All the input-
files are read and converted in turn; if no inputfile is given, the standard input is used. The converted text is printed to standard out-
put.
The encodings permitted are system dependent. For the libiconv implementation, they are listed in the iconv_open(3) manual page.
Options controlling the input and output format:
-f encoding, --from-code=encoding
Specifies the encoding of the input.
-t encoding, --to-code=encoding
Specifies the encoding of the output.
Options controlling conversion problems:
-c When this option is given, characters that cannot be converted are silently discarded, instead of leading to a conversion error.
--unicode-subst=formatstring
When this option is given, Unicode characters that cannot be represented in the target encoding are replaced with a placeholder
string that is constructed from the given formatstring, applied to the Unicode code point. The formatstring must be a format string
in the same format as for the printf command or the printf() function, taking either no argument or exactly one unsigned integer
argument.
--byte-subst=formatstring
When this option is given, bytes in the input that are not valid in the source encoding are replaced with a placeholder string that
is constructed from the given formatstring, applied to the byte's value. The formatstring must be a format string in the same format
as for the printf command or the printf() function, taking either no argument or exactly one unsigned integer argument.
--widechar-subst=formatstring
When this option is given, wide characters in the input that are not valid in the source encoding are replaced with a placeholder
string that is constructed from the given formatstring, applied to the byte's value. The formatstring must be a format string in the
same format as for the printf command or the printf() function, taking either no argument or exactly one unsigned integer argument.
Options controlling error output:
-s, --silent
When this option is given, error messages about invalid or unconvertible characters are omitted, but the actual converted text is
unaffected.
The iconv -l or iconv --list command lists the names of the supported encodings, in a system dependent format. For the libiconv implementa-
tion, the names are printed in upper case, separated by whitespace, and alias names of an encoding are listed on the same line as the
encoding itself.
EXAMPLES
iconv -f ISO-8859-1 -t UTF-8
converts input from the old West-European encoding ISO-8859-1 to Unicode.
iconv -f KOI8-R --byte-subst="<0x%x>"
--unicode-subst="<U+%04X>"
converts input from the old Russian encoding KOI8-R to the locale encoding, substituting an angle bracket notation with hexadecimal
numbers for invalid bytes and for valid but unconvertible characters.
iconv --list
lists the supported encodings.
SEE ALSO iconv_open(3)GNU January 22, 2006 ICONV(1)