-1
votes
0answers
28 views

delete all values in a .csv file besides the name “EC_Customers” and “EC_Leads”

I have a .csv file that has a column for contact tags. In this column, I have a whole bunch of separated tags. I want to delete all of the tags besides "EC_Customers" and "EC_Leads" How do I go ...
1
vote
2answers
37 views

How do I print multiple sections in a text file?

I have a text file looking something like this: *FILESTART line_a line_b line_c *INCLUDE file_A.key file_B.key *INCLUDE file_1.key file_2.key file_3.key *SOMETHING_ELSE line_x line_y line_z *END I ...
-2
votes
2answers
54 views

Trying to count and print song file names using awk

RANK NAME BAND YEAR GENERE DOMESTIC/INTERNATIONAL 206:Reach Out, I'll Be There:The Four Tops:1978:Pop:3/2 207:Bye Bye Love:The Everly Brothers:1950:Classic:3/2 ...
0
votes
1answer
72 views

Extract stings between a delimiter if it matches a certain string

File cat hosts.cfg define host { host_name switchlan alias switchlan address ...
0
votes
1answer
42 views

editing string using sed or grep

first of all please execuse my ignorance on UNIX. I am quite new. I have lot many sql files that contains following string ${DB_USERNAME}.${TABLE_NAME} Can anyone please tell me how could I change ...
1
vote
2answers
59 views

Is there a way to print 2 lines (if any) before and after a target or print a placeholder if not?

I'm not native english speaker so I hope to be clear. I know about grep -C 2 "TARGET" inputfile to select 2 rows before and after the row of the TARGET, but I'm not able to use it to manage my ...
-1
votes
2answers
65 views

how to find number of substrings between delimiter? [closed]

I have the string following something(1)^^^something(2)^^^something(3)^^^ ... ^^^something(n) how to find number of something(s) in the string.
1
vote
2answers
253 views

batch find/replace using sed or awk

In every file with filename matching pattern1 I want to search for lines which start with pattern2, and add some string in a new line above those matched lines. As a simple example suppose I'm ...
2
votes
4answers
3k views

Print line X lines before/after found line

I want to search for a particular string in a certain file. If I found the string, I also want to print the line X lines before (or after) that line. Can this with grep or awk, or do I need a ...
0
votes
2answers
144 views

Replace a Paragraph After a String

I have a text file with a lot of lines and paragraphs I want to replace a string with a line of string Example: Old Text File Sometexts New Text File Sometexts With Some Lines Paragraphs and ...
0
votes
3answers
87 views

Pre-pending to an output line of `tail -f file` if its contents match another file

Trying to cram all of the following into the title was hard, so this is what I really mean: I am doing a tail -F access.log to watch an Apache2 log in realtime. The first thing on each line is an IP ...
0
votes
1answer
145 views

Find a pattern in a line, and append that matched pattern to the same line

I'm trying to pull a job number out of notes listed in a csv, and then append that number to the end of the line, preferably through sed, awk, grep or perl (which I have installed in Cygwin. Here's a ...
0
votes
3answers
2k views

remove text from file

I want to remove some text from file1.txt. I put the text in the file tmp and do: grep -f tmp file.txt But it gives me only the difference. The question is how to remove the difference from ...
0
votes
2answers
86 views

remove the zombie process from the output of ps

I m not looking to kill a zombie process. I m looking to avoid the display of zombie process in the ps command. Are there an option to add to ps command inorder to avoid displaying the zombie ...
1
vote
1answer
136 views

Generate CSV/TXT file from named zone file

I am in need of generating a csv/txt file from a zone file on a named DNS server. For examples I would like to generate a list of the hostname and IP from the zone file From this monkey A ...
0
votes
2answers
2k views

Why escaped single quote doesn't work in grep?

I am trying to match a string: * * * * * /usr/local/bin/growlnotify -t 'helloTitle' -m 'helloMessage' -n 'myApp' -sw with: crontab -l | grep '^[^#].*/usr/local/bin/growlnotify.*\-n \'myApp\'.*$' ...
1
vote
2answers
290 views

netcat output into separate files using string delimiters

I want netcat to pipe the output of a tcp/ip connection to commands that examine the output and split it into distinct files separated by the strings "msg" and "/msg" from the output, something like ...
3
votes
1answer
3k views

Using grep to remove lines from a file which contain a string from another file

I have a file containing words (one per line) such as Dog Fish Cat Shoes I have a secondary file in CSV format such as 1,shoes,red 2,apple,black 3,fog,blue I would like to use grep with ...
1
vote
1answer
238 views

Subtract files from one another recursively between two similar directories

I'm trying to concoct a way to grab two (nearly identical) directories and show me the difference between all files in the two directories. Looking for two different things: 1- List all files ...
0
votes
1answer
555 views

Grep issue (match two strings on same line)

Here I have some grep command which is not working correctly: cat file1.txt: apples Date: Sun, 24 Feb 2013 8:14:06 -0800 peaches melons cherry sky cloud green purple yellow cat file2.txt: apples ...
0
votes
1answer
606 views

Search & Replace Using Grep and Sed Command

I want to remove the weird / special characters from the bunch of text files. Here i used the following command to remove the weird characters but it gives me the error. Command : 1) grep -lri -e ...
1
vote
3answers
3k views

Bash: Find and replace text strings

I figured this would be easy, but I'm overlooking something simple: I have a text file called test. It contains, for example, the string Alfred Hitchcock. I want to replace this with Alfred\ ...
0
votes
4answers
117 views

Simple script parsing text, what is wrong here?

I'm a big user of https://www.grc.com/passwords.htm to get strong passwords. However, having to go to the site and manually copy the password every time gets old fast, so I decided to do a little ...
7
votes
2answers
2k views

Edit first line of large text file

I have a huge text file, far too big for the whole thing to be paged into memory. All I need to do with this text file is edit the first line (its a CSV file and I need to alter the titles). Is there ...
2
votes
1answer
156 views

Grep the whole body of a function

Supposing I know that someFile.php contains the definition for someFunction(). How would I go about displaying the whole body of the function in stdout? If I know that the body is 10 lines long then I ...
2
votes
4answers
842 views

How do you remove all occurrences of values in one list from another list?

I have a list of symbols such as... wer sfe efo How do I remove all instances of these (unique) symbols from another list of (non-unique) symbols? So in the following list, the lines starting ...
3
votes
1answer
801 views

grep, xargs, sed to clean up PHP eval hack

I'm attempting to use the commands found on http://devilsworkshop.org/tutorial/remove-evalbase64decode-malicious-code-grep-sed-commands-files-linux-server/55587/ to clean up a PHP eval based hack on a ...
0
votes
1answer
1k views

solaris 10 + display 2 lines after match by grep?

how to match string , and display the two line under the string for example ( I want to match the "manufacture" string and display the two lines after cat ima.conf # the manufacturer or driver ...
1
vote
2answers
1k views

How to extract e-mail or domain from mixed data file in linux

File content: 17541 From Email subscription@test.com Inbound Policy Manager Envelope Analysis Profiler 17541 From Email subscription@yahoo.com Inbound Policy Manager ...
1
vote
5answers
3k views

How to grep column after second pipe

Example: 3|100|test@test.com|0|0|6:1,10,11,12,13,2,3,4,5,6,9|7:1,10,11,13,16,2,4,5,6,9| Expected view after grep: test@test.com
0
votes
2answers
511 views

Using sed, how to print all lines that match a certain date?

Using sed, how to print all lines where the birthdays are in November or December? Assuming input file name "datebook" as follows: Steve Blenheim:238-923-7366:95 Latham Lane, Easton, PA ...
1
vote
3answers
418 views

How to search file for matching whole lines?

I have a command which sends to stdout a series of numbers, each on a new line. I need to determine whether a particular number exists in the list. The match needs to be exact, not a subset. For ...
5
votes
3answers
533 views

Search for files with more than one term (grep, awk?)

I am using a command like this to find files with the word 'term' in them: grep -l term * But I now want to be able to find files which have two different words in them (let's call them termA and ...
3
votes
1answer
1k views

Finding and deleting lines from all files recursively

I have managed to grep the occurences of a keyword by using grep "KeyWord" . -r -n -i -I but, the occurences of the KeyWord are too large. I just want to delete all the lines containing that word. ...
3
votes
3answers
164 views

unix command to verify span of word in text

What unix command(s) can I use to determine the line span that a word appears in text? The "span" being equal to the line number of the last instance of a word minus the line number of the first ...
2
votes
1answer
80 views

sanity check file to produce binary answer

What Unix command(s) can I use to determine the existence of each of several words and the non-existence of each of several words which will produce a binary answer? For example: I want to be sure ...
0
votes
1answer
383 views

IP Address dotted decimal to /8 or /16 notation using bash,sed or awk?

I have an input file that contains a list of ip addresses and the ip_counts(some parameter that I use internally.)The file looks somewhat like this. 202.124.127.26 2135869 202.124.127.25 2111217 ...
1
vote
3answers
699 views

How do you parse out words from a file?

Hi let's say I have a file that looks like this <jack, john. ................ ,joe ..........Jen.. >Tom Edwa4rd 4Tim Richard How do I turn this into a clean list like jack John joe Jen Tom ...
1
vote
1answer
1k views

I want to get a count of unique entries in the Apache error logs on

When viewing Apache's log files there are a lot of error message repeated. I would like to find out which error messages are most frequent and which are unique. I would like a simple script that can ...
4
votes
4answers
4k views

Print back-reference in regular expression

I was hoping for a way to make sed replace the entire line with the replacement (rather than just the match) so I could do something like this: sed -e "/$some_complex_regex_with_a_backref/\1/" and ...
3
votes
4answers
2k views

How to remove lines from large text file using bash

I got a huge text file (log file) in my CentOS which I would like to remove top part of, probably couple of thousand lines each day. (Or probably just split into two) I have search this site and ...
2
votes
8answers
146 views

How do I remove similar instances of lines using Unix commands?

I have a file that contains lines that look like the following: 14|geauxtigers|90 14|geauxtigers|null I want to remove all instances in the file with the null as the last term. Is there a way to do ...
2
votes
4answers
1k views

How do I write a script that sums the numbers in a file?

I'd like to sum up numbers in a plain text file. Is there somehow I can do this with a command or a bash script? Say I want to extract the number in a pattern that looks like this: … text text … ...
1
vote
2answers
87 views

Trying to cleanse log files on a Linux machine, currently using sed

I have a large amount of log files that I need to remove sensitive data from. The sensitive data is provided to me in a text file and is prone to change. I had hoped to do the equivalent of this: ...
3
votes
4answers
1k views

Search for and print only matched pattern

I have some huge xml text files. I need to write a script to find and print a specific tag only. I tried sed and grep but they both return the whole line. Using SunOS 5.x, so not all linux commands ...
6
votes
7answers
6k views

List only the device names of all available network interfaces

I want to get a list of all available Network-Device Names on my Linux server. I figured that netstat -a would do the job, however netstat produces quite much output: eth0 Link encap:Ethernet ...
0
votes
8answers
238 views

Unix command to list the portion of the end of a log file from a line containing only hyphens to end of file

I have a long log file where each entry begins with a line containg only hyphens.
2
votes
4answers
7k views

grepping a substring from a grep result

Given a log file, I will usually do something like this: grep 'marker-1234' filter_log What is the difference in using '' or "" or nothing in the pattern? The above grep command will yield many ...
2
votes
1answer
1k views

grep + sed for find & replace fun!

I have a dev copy of a website set up that has quite a few hardcoded references to its live counterpart. I would like to replace all occurrences of "www." with "dev." in all files. I think I can use ...
10
votes
4answers
5k views

Better way to do “echo $x | sed …” and “echo $x | grep …”

I often find this in scripts (and, I have to admit, write it myself): a=`echo $x | sed "s/foo/bar/"` or if echo $x | grep foo then ... fi Consider "foo" to include some regex stuff. I feel ...