Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Delete first 2 character from string Post 7861 by devnul on Tuesday 2nd of October 2001 08:06:06 PM
Old 10-02-2001
Try:

substring=`echo $string | sed 's/^..//'`

- dEvNuL
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Korn: How to loop through a string character by character

If I have a string defined as: MyString=abcde echo $MyString How can I loop through it character by character? I haven't been able to find a way to index the string so that I loop through it. shew01 (10 Replies)
Discussion started by: shew01
10 Replies

2. UNIX for Dummies Questions & Answers

Delete between 10th character and 20th character

Hi, I have a .txt and I need to delete the characters betwwen the 10th and 20th... How can I do that... I need to do somethink like these: %s/I don't know how to define a range between 10th and 20th character//g Can you help me... If I want the 10 first characters i do this:... (2 Replies)
Discussion started by: nuno_fbo
2 Replies

3. Shell Programming and Scripting

Delete parts of a string of character in one given column of a tab delimited file

I would like to remove characters from column 7 so that from an input file looking like this: >HWI-EAS422_12:4:1:69:89 GGTTTAAATATTGCACAAAAGGTATAGAGCGT U0 1 0 0 ref_chr8.fa 6527777 F DD I get something like that in an output file: ... (13 Replies)
Discussion started by: matlavmac
13 Replies

4. Shell Programming and Scripting

delete last character in all occurences of string

Hello all, I have a file containing the following p1 q1 p2 q2 p1 p2 p3 pr1 pr2 pr1 pr2 pa1 pa2 I want to remove the last character from all strings that start with 'p' and end with '1'. In general, I do not know what is between the first part of the string and the last part of the string.... (4 Replies)
Discussion started by: bigfoot
4 Replies

5. Shell Programming and Scripting

Delete first character from a string stored in a variable

Hallo! Example. #!/bin/bash BACKUP_DIR=/home/userx/backups/evolution echo $BACKUP_DIR # delete the first character from the string BACKUP_DIR=$(echo $BACKUP_DIR | cut -c 2-) echo $BACKUP_DIR It works. It does want I want, delete the first character from string in the... (11 Replies)
Discussion started by: linuxinho
11 Replies

6. Shell Programming and Scripting

Grep a string from input file and delete next three lines including the line contains string in xml

Hi, 1_strings file contains $ cat 1_strings /home/$USER/Src /home/Valid /home/Review$ cat myxml <projected value="some string" path="/home/$USER/Src"> <input 1/> <estimate value/> <somestring/> </projected> <few more lines > <projected value="some string" path="/home/$USER/check">... (4 Replies)
Discussion started by: greet_sed
4 Replies

7. Shell Programming and Scripting

Sed: delete on each line before a character and after a character

Hi there, A total sed noob here. Is there a way using sed to delete everything before a character AND after another character on each line in a file? The deletion should also delete the indicating characters(here: an opening and a closing parenthesis). The original file would look like... (3 Replies)
Discussion started by: bnbsd
3 Replies

8. Shell Programming and Scripting

sed searches a character string for a specified delimiter character, and returns a leading or traili

Hi, Anyone can help using SED searches a character string for a specified delimiter character, and returns a leading or trailing space/blank. Text file : "1"|"ExternalClassDEA519CF5"|"Art1" "2"|"ExternalClass563EA516C"|"Art3" "3"|"ExternalClass305ED16B8"|"Art9" ... ... ... (2 Replies)
Discussion started by: fspalero
2 Replies

9. Shell Programming and Scripting

Count specific character of a file in each line and delete this character in a specific position

I will appreciate if you help me here in this script in Solaris Enviroment. Scenario: i have 2 files : 1) /tmp/TRANSACTIONS_DAILY_20180730.txt: 201807300000000004 201807300000000005 201807300000000006 201807300000000007 201807300000000008 2)... (10 Replies)
Discussion started by: teokon90
10 Replies

10. UNIX for Beginners Questions & Answers

Delete Directories and its files that begin with the same character string

I wrote a shell script program that supposed to delete any directories and its files that begin with the same character string . The program is designed to delete directories and its files that are one day old or less and only the directories that begin with the same character string. The problem... (1 Reply)
Discussion started by: dellanicholson
1 Replies
wcstombs(3)						     Library Functions Manual						       wcstombs(3)

NAME
wcstombs, wcsrtombs - Converts a wide-character string into a multibyte-character string LIBRARY
Standard C Library (libc.so, libc.a) SYNOPSIS
#include <stdlib.h> size_t wcstombs( char *s, const wchar_t *pwcs, size_t n); #include <wchar.h> size_t wcsrtombs( char *s, const wchar_t **pwcs, size_t n, mbstate_t *ps ); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: wcstombs(): ISO C, XPG4 wcsrtombs(): ISO C Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Points to the location where the converted multibyte-character string is stored. Points or indirectly points to the address of the wide- character string to be converted. Specifies the maximum number of bytes to be stored in the output variable (s). Points to an mbstate_t structure containing the conversion state of the data in pwcs. DESCRIPTION
The wcstombs() function converts a wide-character string into a multibyte-character string and stores the result in a location pointed to by the s parameter. The wcstombs() function stores only the number of bytes specified by the n parameter as the output string. When copy- ing between objects that overlap, the behavior of wcstombs() is undefined. The behavior of the wcstombs() function is affected by the LC_CTYPE category of the current locale. In environments that use shift-state- dependent encoding, the array pointed to by s begins in its initial shift state. The wcstombs() function converts each character in the pwcs wide-character string and stores the converted character in the s string. The wcstombs() function stops storing characters in the output array under the following conditions: The function has encountered a null wide character in the pwcs wide-character string and has written a corresponding null byte in s. The function cannot store the next converted wide character because there is not enough room in s; that is, the function would have to store more than n bytes in the s parameter to store the character. The function has already stored n bytes in the s parameter. The function has encountered an invalid wide-character code in the pwcs wide-character string. If the wcstombs() function stores exactly n bytes in the s parameter, the function does not store a terminating null byte. To ensure that there is enough room in the s parameter to fit the converted string, the application should allocate enough memory to store the maximum multibyte-character string based on the number of wide characters in the wide-character string. Allocate the number of bytes (and pass the value in the n parameter) equal to the length of the pwcs wide-character string (as determined by the wcslen() or wcsrlen() function) multiplied by the value of MB_CUR_MAX in the current locale. A prior call to wcstombs() or wcsrtombs() can perform this calcula- tion for the application. For example, on the first call to wcstombs() or wcsrtombs(), the application can pass s as a null pointer to obtain the number of bytes (not including the terminating null byte) required for s. The application then uses this return value as the value for n in the call to wcstombs() or wcsrtombs() that performs the conversion. The wcsrtombs() function is a restartable version of wcstombs(). Restartable conversion functions obtain and store the conversion state in an mbstate_t structure that can be read and changed by subsequent calls to the same or other restartable conversion functions. Results are undefined when an application uses restartable and nonrestartable conversion functions with the same source and destination variables. For example, an application would use wcsrlen() rather than wcslen() to determine the length of pwcs if that variable were to be processed with wcsrtombs() rather than wcstombs(). RESTRICTIONS
The wcsrtombs() and other restartable versions of conversion routines are functional only when used with locales that support shift state encoding. Currently, the Tru64 UNIX product does not provide any locales that use shift state encoding, so the wcstombs() and wcsrtombs() functions do not differ in terms of run-time behavior. RETURN VALUES
If the wcstombs() and wcsrtombs() functions do not encounter an invalid wide-character code, they return the number of bytes stored, not including the terminating null byte. When these functions encounter a wide-character code that does not correspond to a valid multibyte character, they return a value of -1 cast to size_t and set errno to indicate the error. If the wcstombs() and wcsrtombs() cannot store all of the converted characters in the output array, the functions stop before storing a character that would overflow the output array and return the number of bytes stored in the array. When the return value is n, the output array is not null terminated. If these functions are called with a null pointer value for s, they return the number of bytes required for the output character array. ERRORS
If any of the following conditions occur, the wcstombs() and wcsrtombs() functions set errno to the corresponding value: The array pointed to by the pwcs parameter contains an entry that does not correspond to a valid multibyte character. RELATED INFORMATION
Functions: btowc(3), mblen(3), mbsinit(3), mbstowcs(3), mbtowc(3), wcslen(3), wctob(3), wctomb(3) delim off wcstombs(3)
All times are GMT -4. The time now is 06:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy