Manipulation of text by programs, scripts, etc.

learn more… | top users | synonyms

2
votes
2answers
45 views

Cat files except one [duplicate]

I'm looking for something to concatenate all files with given extension within a directory, except one. Like: cat *.txt !(DISCARD.txt) > catKEPT This should concatenate all *.txt files in ...
9
votes
5answers
288 views

Shell Script: grab string in the middle of the text, sometimes in the beginning

I have a large text file where a part of it looks like this (edited values): JULIANA XXXX006060 LI1033322 THC BRL 730.00 XXXX006296 AA1004737 THC BRL 1,740.00 SANTOS JULIANA XXXX006668 AA1004786 THC ...
4
votes
2answers
420 views

How avoid to repeat the same command in bash script

I have this bash script: gunzip -c /var/log/cisco/cisco.log-$(date +%Y%m%d).gz | awk '/ath_bstuck_tasklet/ { print $4 }' | sort | uniq -c > /tmp/netgear_beacon.txt echo "There are `wc -l ...
2
votes
2answers
32 views

gawk: How i can print output genrated by gawk command in multiple line on terminal in single line in file

I am using gawk command to print column content in file like: gawk '{print $2205764, $2205763}' /home/mohasin/fil1.txt It generates output on terminal with new line: a a b b c c d d . . . . I ...
2
votes
3answers
124 views

Duplicate indexes value in array

Given the files below: file1: 7997,1 7997,2 7997,3 5114,1 5114,2 file2: 7997,52, 5114,12, 4221,52, How can I create an array from the 1st file that has the first column as indices and the ...
0
votes
1answer
31 views

Filter log on final letter in string [closed]

I have a below requirement to filter a word. My logs will be reporting with codes TML2345I,TML8383E & TML9929W. I want to filter the errors only with strings which have the last character as E. ...
3
votes
2answers
60 views

Print common lines between two files along with their line numbers in those files

I have two files. I want to compare the content of one file with the other one. If there is a matching line between both files then print the line and its line number in each file. Example: File 1: ...
5
votes
3answers
61 views

Combine information from two files, line by line

I have 2 files as input: File 1 (space separated) ID POS a0 a1 SNP1 123 A C SNP2 456 T C SNP3 789 G A File 2 (space separated) 0 1 0 1 0 0 0 1 1 1 0 0 1 0 0 1 0 1 1 1 0 0 0 1 Required output A ...
2
votes
2answers
115 views

Curl url txt file, but grep each url seperately from single file

Ok, here's one for you guys that is puzzling me. So I have a text file with lots of url's in it. I'm using curl -K "$urls" > $output to spit the output to my output file. Now for the output of ...
2
votes
2answers
80 views

Insert text in specific lines of a file? with special characters

i know this has been answered several times, but i can't figure out how to use it for my project. i have several php files and want to add a new string between line 11 and 12. this is the string i ...
9
votes
5answers
896 views

Merge two files line by line with the delimiter triple pipe symbol “|||”

I have two parallel files with the same number of lines in two languages and plan to merge these two files line by line with the delimiter |||. E.g., the two files are as follows: File A: 1Mo 1,1 I ...
2
votes
1answer
31 views

To Apply Answers to MCQs

I am now extending my own answers to MCQs, as made How to SED these paragraphs to MCQ format?. Data in file.txt 1 c 2 a Data in exam.tex \item Which of the following lorem ipsun are the best ...
3
votes
2answers
61 views

Replacing strings in file using different values to replace the same pattern

I have such strings in my /etc/mail/virtusertable mail1@example.com error:nouser Account temporary disabled mail2@example.com error:nouser Account temporary disabled mail3@example.com ...
2
votes
4answers
42 views

Remove partial duplicates consecutive lines but keep first and last

I have log files with a time stamp and six values in each line i want to reduce the amount of data, by removing consecutive lines with the same values (ignoring time stamps) and keeping the first and ...
3
votes
1answer
61 views

sed -e 's/^[0-9]//' does not work for the first line

The following is the text I want to parse with sed (Mac OS X 10.11.1 bash) 1 00:25:43,959 --> 00:25:46,502 Here you are, sir. Main level, please. I can delete the first line with sed -e ...
5
votes
5answers
217 views

How to SED these paragraphs to MCQ format?

My data: Question Nr. 311 Main proteins are in the lorem ipsun A Lorem RNA test B Cells C Metoclom D Cells E Muscles Question Nr. 312 Main proteins are in the lorem ipsun A Lorem B Cells C ...
1
vote
1answer
27 views

how replace from A to B comand bash?

i need again your help A: "," B: NEW LINE (DOWN) file.txt: ...
1
vote
0answers
25 views

Scraping from applications other than browsers on Debian Jessie

I'm thinking of building an automated trading system. I think there's probably no services supplying informations of order book and top of book in the txt format. So I have to do scraping. I want to ...
3
votes
1answer
30 views

Replace a control character with another control character

A csv file is being generated with a form feed (\f) character. This makes it hard to read in excel, etc. How can I convert the form feed character into a newline (\n) character? All my searches so ...
2
votes
1answer
65 views

How to find and replace using sed text containing a star *

I would like to find and replace text within many .procmailrc files, and using grep and sed. I would like to remove the following line (including the new line break at the beginning) from the ...
3
votes
3answers
55 views

Sorting more than one column

I have a file which has content that looks like this: 19.58 1925 Alpha 20.40 1924 Otter 13.66 1920 Gold I am trying to sort it "column by column" to output the following: 13.40 1920 Alpha 19.58 ...
3
votes
3answers
59 views

How to delete text in the file before and after some pattern

I have a file with long words without spaces, many lines. file.txt: data-number="210615" ... .... .... ...
1
vote
2answers
32 views

Concatenate selected extensions to output

How to automatically concatenate selected extensions to output with same filename but different extension? Input files (simplified): File1.txt File1.csv File1.tsv File2.txt File2.csv File2.gff ...
3
votes
3answers
149 views

Recursively print file length

How to print the length of all *.txt files in a directory? Eg: Directory content: FileA.txt FileB.txt FileC.txt FileA.csv *.txt length: less FileA.txt | wc -l 43 less FileB.txt | wc -l 13 ...
2
votes
3answers
44 views

How do you append to a variable string in a script?

How do I append a string that has variables in it? sed 's/MIMG109AL1ARP\t[[:alnum:]]*\t/ /g' I initially thought sed, but I don't want to replace anything, I want to add something after the intial ...
2
votes
2answers
58 views

Add Filename as first line of file in shell script

Hello and thanks in advance. I need to take a file, insert the filename as the first line of the file, then move to a different name. Here's the wrinkle. I need to grab the oldest file in the ...
2
votes
1answer
86 views

Modify filenames in Makefile

For reasons that are not important here, I have a source code that I process automatically file-by-file and the processed source files are renamed in a systematic manner. For example, I start out with ...
1
vote
3answers
58 views

bash command: replace “A” to “B” file with long and all symbol letter..?

i need you to help, again.. :-) i love this site unix and linux!! then: A=<item ok:my=world"hello/my.earth/my.land/mycity"><item or mylove:heart="myGIRL" ...
2
votes
1answer
30 views

Regex to match = followed by a newline so they both be deleted

I am working with the raw source content of a mail.app message in OSX, but results it gives me the text in quoted printable MIME Email encoding. so I need to remove all those strange characters to get ...
10
votes
4answers
406 views

How to extract data from a JSON file

I have bin searching a solution for my question but didn't find a or better said I did not get it with what I found. So lets talk about what my problem is about. I am using a Smart Home Control ...
1
vote
4answers
59 views

How to extract part of the line from the file

I need your help: file.txt: hello:"hello"; my love; my world:"my is world" Questions<<my:"475832">> data-addon="652256"---my lover :"987654321";;;Questions heart!Questions but I want ...
1
vote
1answer
49 views

awk is not producing the desired output

Below is my command output. When I process it through awk, it is giving unwanted output. What am I doing wrong? # lvdisplay -m --- Logical volume --- LV Name ...
3
votes
4answers
256 views

How can I delete everything until a pattern and everything after another pattern from a line?

In the following file: Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut eu metus id lectus vestibulum ultrices. Maecenas rhoncus. I want to delete everything before consectetuer and ...
3
votes
1answer
43 views

Exclude similar values from awk

Kindly consider below files: File 1: boo,194,2322 foo,999,7559 File 2: boo,2322 boo,4526 foo,4222 foo,4223 I need to link Field1 in File 1 with Field1 in File 2 and get the related Field2 ...
2
votes
6answers
219 views

Extracting IP address from a text and store it in a variable

I have a text file named abd shown below. 48878 128.206.6.136 34782 128.206.6.137 12817 23.234.22.106 I want to extract only IP address from the text and store it in a variable and use for other ...
2
votes
1answer
52 views

How to enter a sum derived from awk in the middle of text output [closed]

I am trying to print a sum in the middle of a line. My script prompts for a user name and then pulls a total number of processes and a total of time for that user from a file. I want to print a ...
4
votes
3answers
154 views

Concatenate several files with a common header

I have several text files, and each file's content is like attribute1,attribute2,... 1,2,... The first lines which describe the names of the columns are the same in all the files. I want to ...
3
votes
4answers
82 views

Split columns based on patterns in fields

Example: I'd like to split $2 in input file, putting a tab after pattern surname Input: name surname1 name surname30000 name surname456 Desired output: name surname 1 name ...
1
vote
2answers
41 views

How to remove double quotes & dots altogether from a file

I have below file content from which I want to remove double quotes " and dot .: Password expiration notice for beems Server # cat pschagKK Password expiration notice for "beems" Server.example.com ...
1
vote
1answer
44 views

Shell script: Text files to array

I must use C-shell. I have a 40+ list of ip and hostname in text file. sat1 100.34.54.65 sat2 100.34.54.55 sat3 100.34.54.45 and so on.. i want to set the ip and hostname as list of array. The ...
2
votes
1answer
19 views

Script to parse fields

I need some help in parsing a file & extract certain fields from the same : Sample file format : "make":"honda","group":"xyz","model":"accord","year":"2007","miles":"67000" ...
3
votes
3answers
102 views

Find and replace with contents of a file

I have a file that begins with a few "include" statements, like this: include foo.xyz include bar.xyz do c do d Suppose the file foo.xyz contains do a and the file bar.xyz contains do b. How can I ...
5
votes
1answer
81 views

How to find the most frequent word of each file in a directory?

I need to find the most frequent word of each file in a directory and print it like this : 12 my /home/test/file1.txt 5 you /home/test/file3.txt 7 hello /home/test/file4.txt I tried: for tmp in ...
1
vote
2answers
38 views

USB data logging Ubuntu MATE

Using Ubuntu Mate, raspberry pi. I am new to programming and very new to bash. Simply put: USB data to CSV, I can try anything even without script. Edit: The device will be in loop, so stopping it to ...
0
votes
3answers
60 views

Edit an xml file - Find a string then Delete a block of text / Find a string then Insert a new block of text

Morning All, I'm new to UNIX so looking to do something I can do in VB but don't have the experience to do in UNIX. I have an xml spec on a share which requires regular deletion and updates as new ...
1
vote
2answers
81 views

Creating a spreadsheet from a text file

I am writing a shell script which takes a text file as input and generate a spreadsheet as output. I have single text file similar to the one shown below. Name:John Age:30 Gender:male Name:Bob Age:65 ...
1
vote
0answers
30 views

cat specific lines from file [duplicate]

I have a 300000 lines in a text file. And I have a file with list of line numbers that I need to extract from text file. Numbers are ordered. They are not ranges and there are about 4000 of them. So I ...
2
votes
1answer
32 views

Remove multi lines non-greedy

I have a log file that contains many lines, such as: 2015-xx-yy bla bla 2015-11-09 23:59:18.167 Describe ▶ FOO dummy dummy dummy dummy dummy "BAR" 2015-xx-yy foo foo 2015-xx-yy bar bar ...
1
vote
1answer
20 views

Making a fasta file from 2 different files

I have 2 files file1.seq and file2.seq. They look like these: file1.seq ACGGTGTGATG file2.seq CGTGATGATGT I want to make one fasta file which would be like: >file1.seq ACGGTGTGATG ...
1
vote
3answers
49 views

Compare two files column values using awk

Here is the content of two files : Judi # cat File1 judi /export/home 76 judi /usr 83 judi # cat File2 judi /export/home 79 judi /usr 82 If column 3 of File2 is greater that column 3 ...