Sponsored Content
Top Forums Shell Programming and Scripting Finding a string in a text file and posting part of the line Post 302406921 by Jairaj on Wednesday 24th of March 2010 07:33:57 AM
Old 03-24-2010
Try this also using awk:
Code:
awk '{if (substr($0,1,10) == "helloworld") {print substr($0,11)} else {print substr($0,1)}}' file


Last edited by Scott; 03-24-2010 at 05:59 PM.. Reason: Code tags, please...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding a certain string on each line in a file

Hi, I need a script to get every line from a file where there are less then 17 ; on a line. Thank's (5 Replies)
Discussion started by: VODAFUN
5 Replies

2. Shell Programming and Scripting

Finding part of a string

Hi I am very new to KSH programming and need some help with finding a string in an error log currently i am doing cat FTP_LOG.lis | grep Warning which gives me Warning: Authentication failed. Remaining authentication methods: 'publickey,pas I want to only pick up the test between the... (4 Replies)
Discussion started by: DAFNIX
4 Replies

3. UNIX for Dummies Questions & Answers

how can search a String in one text file and replace the whole line in another file

i am very new to UNIX plz help me in this scenario i have two text files as below file1.txt name=Rajakumar. Discipline=Electronics and communication. Designation=software Engineer. file2.txt name=Kannan. Discipline=Mechanical. Designation=CADD Design Engineer. ... (6 Replies)
Discussion started by: kkraja
6 Replies

4. Shell Programming and Scripting

How to insert string at particular 4th line in text file

I just want to add a particular string in text file using shell script text file format 1 columns-10 2 text=89 3 no<> 4 5 test-9876 6 size=9 string need to insert in 4th line <switch IP='158.195.2.567' port='5900' user='testc' password='asdfrp' Code='8'> After inserting the... (8 Replies)
Discussion started by: puneet.goel
8 Replies

5. Shell Programming and Scripting

Reformatting single column text file starting new line when finding particular string

Hi, I have a single colum file and I need to reformat the file so that it creates a new line every time it come to an IP address and the following lines are corresponding rows until it comes to the next IP address. I want to turn this 172.xx.xx.xx gwpusprdrp02_pv seinwnprd03... (7 Replies)
Discussion started by: kieranfoley
7 Replies

6. Shell Programming and Scripting

[Solved] Printing a part of the last line of the specific part of a file

Hi, I have 80 large files, from which I want to get a specific value to run a Bash script. Firstly, I want to get the part of a file which contains this: Name =A xxxxxx yyyyyy zzzzzz aaaaaa bbbbbb Value = 57 This is necessary because in a file there are written more lines which... (6 Replies)
Discussion started by: wenclu
6 Replies

7. Shell Programming and Scripting

Search a string in a text file and add another string at the particular position of a line

I am having a text file which is having more than 200 lines. EX: 001010122 12000 BIB 12000 11200 1200003 001010122 2000 AND 12000 11200 1200003 001010122 12000 KVB 12000 11200 1200003 In the above file i want to search for string KVB and add/replace... (1 Reply)
Discussion started by: suryanarayana
1 Replies

8. Shell Programming and Scripting

Search a string in a text file and add another string at the end of line

Dear All I am having a text file which is having more than 200 lines. EX: 001010122 12000 BIB 12000 11200 1200003 001010122 2000 AND 12000 11200 1200003 001010122 12000 KVB 12000 11200 1200003 In the above file i want to search for string KVB... (5 Replies)
Discussion started by: suryanarayana
5 Replies

9. Shell Programming and Scripting

Reading text file, comparing a value in a line, and placing only part of the line in a variable?

I need some help. I would like to read in a text file. Take a variable such as ROW-D-01, compare it to what's in one line in the text file such as PROD/VM/ROW-D-01 and only input PROD/VM into a variable without the /ROW-D-01. Is this possible? any help is appreciated. (2 Replies)
Discussion started by: xChristopher
2 Replies

10. Shell Programming and Scripting

Finding pattern in a text file and returning a part of the word

Dear All, assume that we have a text file or a folder of files, I want to find this pattern followers*.csv in the text file , and get * as the output. There are different matches and * means every character. Thank you in advance. Best, David (1 Reply)
Discussion started by: davidfreed
1 Replies
tapset::string(3stap)													     tapset::string(3stap)

NAME
tapset::string - systemtap string tapset DESCRIPTION
strlen Returns the length of a string See function::strlen(3stap) for details. substr Returns a substring See function::substr(3stap) for details. stringat Returns the char at a given position in the string See function::stringat(3stap) for details. isinstr Returns whether a string is a substring of another string See function::isinstr(3stap) for details. text_str Escape any non-printable chars in a string See function::text_str(3stap) for details. text_strn Escape any non-printable chars in a string See function::text_strn(3stap) for details. - strtol Convert a string to a long See function::-strtol(3stap) for details. isdigit Checks for a digit See function::isdigit(3stap) for details. SEE ALSO
function::strlen(3stap), function::substr(3stap), function::stringat(3stap), function::isinstr(3stap), function::text_str(3stap), function::text_strn(3stap), function::-(3stap), function::strtol(3stap), function::isdigit(3stap), stap(1), stapprobes(3stap) IBM
--- tapset::string(3stap)
All times are GMT -4. The time now is 12:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy