Skip to main content

All Questions

Tagged with
-1 votes
3 answers
320 views

Need to format text file and update based of key value format

I have a file having the below values: cat data.txt server1: calv server2: anot log: /u/log/1 server3: calv server4: anot server5: secd server6: calv LIB_TRGT_calv,anot: /tmp/hello.txt LIB_TRGT_secd: /...
Ashar's user avatar
  • 511
3 votes
2 answers
8k views

How to search for a string in a very large file with very long lines?

It turns out I was accidentally using grep wrong yesterday. I just checked my bash history and saw what I was executing: grep search-string-here -f large-file-with-long-lines.txt And that was what ...
hilltothesouth's user avatar
0 votes
1 answer
102 views

Print Multiple Substrings Including an IP Address

Good day! I have a giant input file that displays a lot of garbage and I would like to export multiple substrings. The problem is that sometimes additional information is injected into the file making ...
DD-Nerd's user avatar
  • 55
0 votes
1 answer
81 views

How to grep/sed a defind part of string that has spaces

I have a log that contains records like: LineFFF 1234567 0002 @2018-06-12T17:02:50 (len:0) 99 OK : jAFoSSYut2iJLmrk6fdQPL4OMRgd1Ybzb6U9MG1GeWKWqXlYPyfzyMVb9zn3 LineFFF 1234568 0044 @2018-06-12T17:...
rack201's user avatar
0 votes
4 answers
818 views

Removing lines whose first column is duplicated

I have a file where strings are separated by a special string (not a comma or delimiter) e.g. <vvv>. I want to check if all strings in the first field are unique. If duplicate rows for the same ...
user9371654's user avatar
0 votes
2 answers
1k views

How can I add incremental integer row in a text file using grep or awk command in linux terminal?

I have a text file which contains 10 million+ lines. The file looks like as bellow: 1902400023 1902400029 1902400031 1902400032 I wanted to add a heading, incremental ID number and a constant ...
Rezuan's user avatar
  • 253
1 vote
4 answers
737 views

How to process a column's multiple strings

I have a comma separated file that looks similar to his format: aa.com,1.21.3.4,string1 string2 K=12 K2=23 K3=45 K4=56 bb.com,5.6.7.8,string1 string2 K=66 K2=77 K3=88 K4=99 I want to take ...
user9371654's user avatar
2 votes
4 answers
3k views

How to extract columns before and after a string ocurrence

I have a text file. That looks like: www.ac.com has address 6.1.1.146 www.ac.com is an alias for ac.com. www.ac.com is an alias for ac.com. www.ba.net is an alias for www-bn.gs.ba.com. www-bn.gs.ba....
user9371654's user avatar
0 votes
1 answer
369 views

AWK / String manipulation: How to pull strings out from a column and compare it with a number before printing the row

I have a list of data in a table. By using awk to pull out column 5, i was able to differentiate the data amongst the rows. If the entry at column 5 is more than 4, the row should be printed. ...
tthhss's user avatar
  • 51
0 votes
1 answer
298 views

Remove lines between special characters in Unix [closed]

In my code/text file whatever is between /* and */ is commented - I have to remove this commented code from my text/code file $ cat codefile.txt /*~BB~************************************* asdasd ...
karan's user avatar
  • 1
1 vote
2 answers
2k views

Grep from the last occurrence of a pattern to another pattern

Good morning, I am trying to write a UNIX script for a file with multiple duplicate patterns, followed by the pattern I am looking for. This question is very similar to: "Get the last occurrence of ...
Henry's user avatar
  • 99
1 vote
3 answers
271 views

How to use sed to print part of a string containing hashes (or any alternative solution)?

I am trying to print out a specific string within a line with sed. The first problem is that I have some difficulties finding a string which contains slashes, I already tried some solutions provided ...
Flemx's user avatar
  • 13
1 vote
3 answers
4k views

Find and delete lines containing multiple patterns in a file

I have a list of strings and want to find and delete lines containing these strings in a file. A short example of the list of strings is listed as below. File S 1Mo 32,33 2Mo 7,26 2Mo 7,27 2Mo 7,28 ...
Frown's user avatar
  • 197
2 votes
2 answers
1k views

Match lines beginning with the same pattern in two text files

I am now having two text files with some of the lines beginning with the same pattern. For example, File A 1Mo 1,1 I love you. 1Mo 1,2 I like you. Hi 23,3 I am hungry. Hi 23,4 I am foolish. File B ...
Frown's user avatar
  • 197
1 vote
1 answer
599 views

Reading a string till a key word and replacing from there with another string

I am new to UNIX and am practising shell scripting. I have an application where I need string searching and replacement. There are some lines in a file 1 and file 2. I have a search key word. If the ...
user168983's user avatar

15 30 50 per page