Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

strltrim(3pub) [debian man page]

STRLTRIM(3pub)						       C Programmer's Manual						    STRLTRIM(3pub)

NAME
strltrim - remove leading whitespace from string SYNOPSIS
#include <publib.h> char *strltrim(char *s); DESCRIPTION
strltrim removes all leading whitespace characters from the beginning of a string, by moving everything starting from the first non-white- space character to the beginning of the string. As whitespace is counted everything for which isspace(3) returns true. RETURN VALUE
strltrim returns its argument. EXAMPLE
To remove all indentation from all lines in a program, you might do the following: #include <publib.h> int main(void) { char line[512]; while (fgets(line, sizeof(line), stdio) != NULL) { strltrim(line); printf("%s", line); } return 0; } SEE ALSO
publib(3), strrtrim(3), strtrim(3), isspace(3) AUTHOR
Lars Wirzenius (lars.wirzenius@helsinki.fi) Publib C Programmer's Manual STRLTRIM(3pub)

Check Out this Related Man Page

STRSUB(3pub)						       C Programmer's Manual						      STRSUB(3pub)

NAME
strsub - substitute first occurence of pattern with another string SYNOPSIS
#include <publib.h> char *strsub(char *str, const char *pat, const char *sub); DESCRIPTION
strsub finds the first occurence of the pattern pat in the string str (using a method similar to strstr(3), i.e., no regular expressions), and replaces it with sub. If pat does not occur in str, no substitution is made. Of course, if sub is an empty string, the pattern is deleted from the string. RETURN VALUE
strsub returns a pointer to the first character after the substitution, or NULL if no substitution was made. EXAMPLE
To substitute up to two occurences of "foo" with "bar" in a line, one might do the following. p = strsub(line, "foo", "bar"); if (p != NULL) strsub(line, "foo", "bar"); SEE ALSO
publib(3), strstr(3), strgsub(3) AUTHOR
Lars Wirzenius (lars.wirzenius@helsinki.fi) Publib C Programmer's Manual STRSUB(3pub)
Man Page

15 More Discussions You Might Find Interesting

1. Programming

isspace?

Hello, Does somebody know what is happening here? This piece of code should skip leading spaces (and others). If isspace encounters a non space character, it doesn't return false. If we analyze the " isspace(*cs_str);" in the debugger, it returns 0. If we check the value in b_space after... (4 Replies)
Discussion started by: Micky
4 Replies

2. Shell Programming and Scripting

SED: Matching a string with whitespace?

I am trying to search through a text file and replace the number 1 at the beginning of the string in the second field with the number 9. There maybe one or more occurrences of whitespace between the string GPA131 and 17049333610. Does anyone know how to do this with sed? GPA131 17049333610 ... (1 Reply)
Discussion started by: cstovall
1 Replies

3. Shell Programming and Scripting

Delete whitespace

Hi, I have been trying to remove whitespace from a file using sed. Here is an example of what im trying to do: www1 = www1 www2 = www2 www3 = www3 and all the way to 300 and i want it to look like: www1=www1 www2-www2 www3=www3 again upto 300 Any help... (12 Replies)
Discussion started by: truck7758
12 Replies

4. Shell Programming and Scripting

remove leading spaces from a line

Hi friends I need some help, I have a file which looks as follows TEMP 014637065 014637065 517502 517502 RTE 517502 517502 RTE AWATER_TEST 12325 23563 588323 2323 5656 32385 23235635 ANOTHER_TEST 12 5433 FTHH 5653 833 TEST 123 123 3235 5353 353 53 35 353 535 3 YTERS GJK JKLS ... (6 Replies)
Discussion started by: lijojoseph
6 Replies

5. Shell Programming and Scripting

How to remove new line char from a string

Hi Can anyone tell me how can i remove new line character from a string. My requirement is to read a line from a file and store it to a string. read line string1=$line read line string2=$line echo $string1$string2 The result i am getting in different line. i want the output in the same... (1 Reply)
Discussion started by: sreedivia
1 Replies

6. UNIX for Dummies Questions & Answers

remove whitespace

I combined 2 files using the paste command. It gave me something like this: 123445 ,AABBNN 22344 ,BBVVMM I want to remove the whitespace between the end of string 1 and the comma (there is more blank space than my post is showing). Would I... (2 Replies)
Discussion started by: nickg
2 Replies

7. UNIX for Advanced & Expert Users

whitespace problem

I have a single string as below: Rat run after Cat i.e. there is a single whitespace after Cat. This causes my file to fail. Is there a way I can remove any whitespace at the end of any string. I tried sed 's/ *//g', but it removes all white space and the above string becomes... (10 Replies)
Discussion started by: RubinPat
10 Replies

8. Shell Programming and Scripting

Not able to remove leading spaces

Hi Experts, In a file tht i copied from the web , i am not able to remove the leading white spaces. I tried the below , none of them working . I opened the file through vi to check for the special characters if any , but no such characters found. Your advice will be greatly appreciated. sed... (5 Replies)
Discussion started by: panyam
5 Replies

9. Shell Programming and Scripting

Removing whitespace issue

Hi, I have a file with rows like below delimited with pipe (|) I want to remove all the leading and trailing white space from each and every fields keeping the delimiter intact. I have tired this sed 's/*//g;s/*$//g' but the result is incorrect it is removing a whitespace from... (6 Replies)
Discussion started by: COD4
6 Replies

10. Programming

Annoying whitespace after a char string...

Greetings everyone! I keep getting a very long whitespace after some char strings I'm outputting. This is the function where I input the names, last names...: void add_to_list (void) /* Add a new name to our address book */ { ADDRESS *new_name; FILE *outfile; new_name=... (4 Replies)
Discussion started by: Nephilim.F
4 Replies

11. Shell Programming and Scripting

remove all occurrences of a character at the beginning of a string

Hi there, i need some help to remove all occurrences of a certain character at the beginning of a string. Example: my string is 00102030 and i want to remove all zeros from beginning of string so the result is 102030 (3 Replies)
Discussion started by: gigagigosu
3 Replies

12. Shell Programming and Scripting

How to remove , if first character on line

Hi, I have a file with lines such as the below. I want to remove the comma only if it is the first character on a line. I can't work out how to do this using sed. *ELSET, ELSET=WHEEL_TD2 63, 64, 65, 72, 82, 88, 89, 92, 120, 121, 152, 181, 190, 221, 252, 259 , 260, 282, 283, 285, 286,... (2 Replies)
Discussion started by: carlr
2 Replies

13. UNIX for Dummies Questions & Answers

[Solved] How remove leading whitespace from xml (sed /awk?)

Hi again I have an xml file and want to remove the leading white space as it causes me issues later in my script I see sed is possible but cant seem to get it to work I tried sed 's/^ *//' file.xml output <xn:VsDataContainer id="1U104799" modifier="update"> ... (10 Replies)
Discussion started by: aniquebmx
10 Replies

14. Shell Programming and Scripting

Preserve leading white space

I have about 350 programs in which I have to add 2 lines; one before and one after a specfic line. The following script does the job except that I lose the indentation. #!/usr/bin/bash while read line ... (8 Replies)
Discussion started by: jgt
8 Replies

15. UNIX for Advanced & Expert Users

Vi remove line range containing a string

In vi I would like to remove a line containing a string. I thought after reading this I could do this. https://www.unix.com/302297288-post3.html :'3560,3572/gcc/d' It keeps complaining vi mark not set. And sometimes it complains E488: Trailing characters. I don't understand what mark... (5 Replies)
Discussion started by: cokedude
5 Replies