Deleting a line from a file based on one specific string instance?
Hello!
I need to delete one line in a file which matches one very precise instance of a stringonly. When searching the forum I unfortunately only found a solution which would delete each line on which a particular string occurs.
Let's assume I have a file composed of thousands of lines and let's call the file chap-secrets. Let's take the following sample entries:
The usernames are unique, naturally.
I would now like to delete the line containing the username "pp" only. The following suggestion has been made in a related thread:
However, this doesn't work here, for it would delete (or rather not store) all these lines, because all lines with the usernames "cpp", "hopp" and "flopps" are valid matches, all lines with the server name "pptpd" are valid matches and all lines where the password contains a "pp" (such as "ppbbbbpp") are valid matches, too, and these lines all would be deleted (or rather not stored) as well.
Note that the number of spaces between the fields differ as well all the time, so I can't search for a pattern like
either.
I suppose this problem is very simple for some of you, but for me it's not, thus every help would be very much appreciated.
In the file below I am trying to extract a specific instance of path, if the adjacent plugin": "/rundb/api/v1/plugin/49/. Thank you :).
file
"path": "/results/analysis/output/Home/Auto_user_S5-00580-4-Medexome_65_028/plugin_out/FileExporter_out.52", "plugin": "/rundb/api/v1/plugin/49/",... (8 Replies)
I am trying to add a condition to the below perl that will capture the GTtag and place a specific string in the last field of each line. The problem is that the GT value used is not right after the tag rather it is a few fields away. The values should always be 0/1 or 1/2 and are in bold in the... (12 Replies)
I'm trying to create a script.
There are 2 files - fileA.log & fileB.log
fileA.log has the below data :
aaaa
cccc
eeee
fileB.log has the below data :
cjahdskjah aaaa xyz
jhaskjdhas bbbb abc
ajdhjkh cccc abc
cjahdskjah ... (7 Replies)
HI
Can any one guide me how to achieve this task. I have 2 files
env.txt
#Configuration.Properties values
identity_server_url = http://identity.test-hit.com:9783/identity/service/user/register
randon_password_length = 6
attachment_file_path = /pass/temp/attachments/... (1 Reply)
Hi,
I want to achieve something similar to what described in another post:
The difference is I want to add the line if the pattern is not found.
File 1:
A123, valueA, valueB
B234, valueA, valueB
C345, valueA, valueB
D456, valueA, valueB
E567, valueA, valueB
F678, valueA, valueB
... (11 Replies)
Hi
I am not the best scripter in the world and have run into a issue which you might be able to guide me on...
I have two files.
File1 :
A123, valueA, valueB
B234, valueA, valueB
C345, valueA, valueB
D456, valueA, valueB
E567, valueA, valueB
F678, valueA, valueB
File2:
C345,... (5 Replies)
Hi all,
I have a directory containing many subdirectories each named like KOG#### where # represents any digit 0-9. There are several files in each KOG#### folder but the one I care about is named like KOG####_final.fasta. I am trying to write a script to copy all of the KOG####_final.fasta... (3 Replies)
HI,
Your help was great: awk -F":" '$5 ~ /^P/{print }' file
I would like to know what changes need to be done to this line code, so that I can put it in a shell script and call it as the example below.
example: countries that start with chacater 'P'
> country P
Result:
... (0 Replies)
Hi,
I have a file that has several values seperated by ":"
2006:John:Student:Football:Portugal:Cinema
2006:James:Engineer:Basket:Poland:Theatre
2007:Lucy:Diver:Gymnastic:England:Music
2007:Smith:Plumber:Basket:Spain:Poker
I need make a filter based on the 5th field to find countries that... (1 Reply)