Manipulation of text by programs, scripts, etc.

learn more… | top users | synonyms

3
votes
3answers
99 views

Parse multiple sections of data into seperate files

I have a concatenated log file with multiple logs inside that I'm trying to parse out into individual log files (I will later rename them to the date/time of each). Each log is separated by "--- LOG ...
2
votes
2answers
23 views

removing each . after ] appear in a line in complete text file

I have a file in which I need to eliminate . after the ] on every line e.g xyz[1.2]35.23 xyz[1.2.3]35.234 output should be xyz[1.2]3523 xyz[1.2.3]35234
1
vote
2answers
25 views

Transform custom tags with arguments

I want to write my diploma theses with markdown. Sadly, there is no perfect editor and so I have to improvise. For bibtex citations I want to transform my own definition with some sort of bash-filter ...
-3
votes
0answers
23 views

Parsing the log file test into tabular format

How to display below test file in tabular format as below: Output should be like: ma1-test1.cor.dns.com cmd - ...
2
votes
2answers
188 views

Get text between a word and the last line?

According to the answers in Stack Overflow question How to use sed/grep to extract text between two words?, we can get text between two words: sed -n "/first/,/second/p" file But what if I want to ...
2
votes
1answer
26 views

Calculate Apache's response time for last 10 seconds

I have the next apache's log format: LogFormat "%h %l %u %t \"%r\" %>s %b %D \"%{Referer}i\" \"%{User-Agent}i\"" where's %D - The time taken to serve the request, in microseconds. I want to ...
0
votes
4answers
59 views

How print only the current logged in “root” user IP address?

Currently I can see my (root) IP address on top of the output for this command: last But what I want is just that the IP address is printed out to me in a clean way. root pts/1 1.1.1.1 ...
1
vote
3answers
32 views

Trouble in adding a column with awk

I'm trying to add a column to a csv file by using: awk -F "," '{print $0"new_col"}' file.csv but I got : new_col8,0.405,0.101 new_col4,0.374,0.100 new_col23,0.342,0.100 new_col130,0.298,0.100 ...
5
votes
4answers
421 views

How can I “lazily” read output from xrandr?

I have a bash script that I use to adjust my monitor brightness that uses xrandr --verbose to get the current brightness. It works fine, but using xrandr is kind of slow on my machine, as you can see ...
5
votes
4answers
205 views

How to replace all the first occurences in matched lines with incremental number?

I have a file like this ... 1562 first part 1563 H col3 H col4 1564 H col3 H col4 ... 3241 H col3 H col4 3242 third part ... I want to replace only the first H in every line to H#, with ...
-1
votes
2answers
14 views

Design the Code to combine the splitted files based on serial,pin,denomination [on hold]

source is a directory contain two files s1 and s2. These files contain some data in columns: serial,pin,denomination datas. This should be moved to another directory called destination with ...
0
votes
1answer
30 views

How do I validate a settings(ini) file for the values expected using bash?

After I check if the ini file exists where it is expected to be, which I've learned how to do, I would like to check the file for proper formatting. I'd like to validate any number of "site" entries ...
0
votes
1answer
21 views

Compare strings

I have 2 txt files, in one i have alias lists and the other is the servers name. So what im trying to do is to loop from the alias txt file line by line and where it will find the name that is on the ...
2
votes
1answer
20 views

Get each column which contains multiple spaces?

My file: subnet 172.25.10.0 netmask 255.255.255.0 { option domain-name-servers 172.25.10.9, 8.8.8.8; default-lease-time 300; max-lease-time 7500; range dynamic-bootp 172.25.10.10 172.25.10.30 ; ...
-3
votes
0answers
47 views

How to make webpages concise? [closed]

concise:I've programmed >20 years taught ~1000 hours ~6 courses. Mixed list of wisdom I tell my students ≥1 time: normal:I've been programming for over 20 years, and I've run about half a dozen ...
-2
votes
3answers
48 views

How to sed two same value without affecting the other

I have an xml file and I want to change one value on that file: param name=swam_license_ports_overdraft_thresh 99 param name="strike_license_ports_overdraft_thresh" 99 The outcome I want is to ...
3
votes
2answers
94 views

Identify lines that are out of order

I have a process that generates output mostly in lexicographically sorted order according to a (timestamp) field, but occasionally the lines will be output in the wrong order: 2014-08-14 ...
4
votes
6answers
279 views

want the last line when duplicate awk?

I have the file: key value blah blah blah blah blahblah man1 boy1 blah blah man1 boy2 man1 boy1 I do this to remove duplicate lines: awk '/man1/ { print $1,$2} ' file | awk '!x[$0]++' and the ...
1
vote
2answers
118 views

Joining files on disk

Say I have several file with the following naming: 000001 000002 000003 ... Each of these files is a csv file (may include escape characters). In total the folder has ~20GB of data. How can I ...
3
votes
2answers
135 views

How to count how many different word do i have in a file, in a column

I have a CSV file. "AGNOLI Valerio","ITA","AST" In this example, the 2nd column says "ITA". I expect there are about 100 or so different nationalities listed in this file. I want to know exactly ...
3
votes
1answer
38 views

Handling dynamically changing column positions and splitting file

I have a unique problem. I have a file with following columns PersonId, AB1, AB2, AB3, DG1_B1,DG1_B2,DG2 1,0,1,0,3,5,7 2,0,3,1,3,7,4 I want to split this and create multiple files based on the ...
-2
votes
2answers
70 views

Text processing using unix tools

I have a file in the following format. abc|xyz|mno x up x up up x x x up abc|xyz|mno x x x up x x .... .... Basically the first line of the file are device names (|ed) and ...
1
vote
1answer
33 views

Why might these values not be uniq'ed together?

I am trying to figure out which IP addresses hit the server most often. I received this surprising output from uniq: $ cat access_log | awk '{print $1}' | uniq -c | sort -bnr | head 26 73.23.5.25 ...
4
votes
6answers
148 views

grep with a lot of files which contains a lot of lines?

Imagine we have a lot of huge(30000 line)files: a.2014-05-06, a.2014-05-07, a.2014-05-08 and so on. I know that we can grep a line with word using this command: grep "word" a.* First I guess this ...
2
votes
4answers
65 views

Insert new line after non matching pattern

I have following output from script host1:101 host1:102 host2:101 host2:102 host2:103 host4:101 host5:101 host5:102 host5:103 host5:104 etc.. I wanted to insert a new line after each host group. ...
3
votes
3answers
80 views

How can I delete text before a delimiter in Linux

I need to delete text from a line before delimiter. For example: (123434): hello::{apple,orange,mango}. I need to delete text before first :. i.e. (123434). Is there any command in linux to ...
1
vote
3answers
30 views

Increment a date in a file

I have a file with single line of text inside.How can I modify its content without using the vi editor.Below is the example: PROCESS DATE =2014-08-01 I want to increment the "2014-08-01" by the ...
0
votes
2answers
40 views

Text File Renaming Using Script

I have thousands of text files inside a folder and they are named in a certain way. For example: Image_234_Data_7778_n0.txt Image_234_Data_7778_n1.txt Image_234_Data_7778_n2.txt ...
2
votes
6answers
412 views

Handling comma in string values in a CSV file [duplicate]

I have a comma-separated file which has numeric and string columns. String columns are quoted and can have comma in between the quotes. How do I identify the columns with FS =","? Sample records ...
1
vote
3answers
62 views

merging all files into one file?

I was trying to merge all the text files in to one file. All the text files has one column and equal number of rows. My data file names are data_1.txt, data_2.txt, data_3.txt, . . . data_n.txt. ...
5
votes
2answers
71 views

Extract tomcat parameters from ps output

I'm trying to write a little diagnostic tool and one of the functions I want from it is that I want to run is: ps axu | grep tomcat | grep -v grep | awk '{ print $<list of desired fields> }' ...
0
votes
2answers
100 views

Delete every number that comes before “=”

i have a very, very, very long list. Like over 830,000 characters. I will of course perform said command on a copy. There are multiple lines, like this hey1=lol hey2=lol hey3=lol I want that to ...
2
votes
2answers
103 views

Collate tab-delimited files

I want to compare the information from mapping files to retrieve crosslinked information in a tab-delimited file format. For example, one file contains COG0001 882.DVU3168 COG0002 883.DvMF_2502 ...
0
votes
3answers
34 views

Delete everything not matching this pattern 'something.swf' in txt file

Can sed or awk do this, what I want do to is delete everything not matching this pattern 'something.swf' It doesn't need to be these commands. And im kind off new the text processing via the terminal ...
1
vote
3answers
38 views

How to convert &#x119; to letter?

I want html number entities like &#x119; and want to convert it to real character. I have emails mostly from linkedin that look like this: chcia&#x142;abym zapyta&#x107;, czy ...
4
votes
2answers
83 views

Convert file with integers written in ascii to binary file of integers

I have a file that contains a long list of integers written in ascii separated with newlines, like such: -175 2 -19345 345592 -45 2355 etc... I want to convert this file into a "binary" file ...
1
vote
4answers
82 views

Bash: Convert Multi-line output to Single line

I am getting a multi-line output as follows: Actual Output: GenuineIntel,Intel(R) Xeon(R) CPU E5-2687W 0 @ 3.10GHz,CPU0,64,EM64T Family 6 Model 45 Stepping 7,(null),3093,0 GenuineIntel,Intel(R) ...
-3
votes
2answers
47 views

Extract certain column from CSV files [closed]

I have a directory with a group of CSV files. All files have the same column headers. I need to extract values in a certain column from all files. The common part in files names is ...
0
votes
1answer
33 views

Delete all lines containing “..” and “@”

I have a long text file from a tcpdump. I need some of the information but most lines are just like this: .....@isa..g..3..2..2.@...3.3.2.1.12.. I want to use sed to search and replace all lines ...
2
votes
3answers
82 views

Replace a word after a significant line and white spaces (inline) using sed?

I have the following text: A Hello world B Hello world C Hello world I know that I can replace Hello by Hi using sed: sed 's/Hello/Hi/g' -i test but this replace each Hello ...
2
votes
3answers
29 views

Delete until given character starting from given string

root@server:~/foo$ cat INPUT.txt limit. Current u'^'ZO limit. Current usage'^'FR limit. Current us'^'AS limit. Current usage 95 %.'^'FR limit. Cur'^'AEW root@server:~/foo$ sed ...
4
votes
1answer
72 views

Using sed command convert only first character in specific line with uppercase

How can I convert the first character of each word in the line after gr-description: to uppercase? For example : $ cat /tmp/test1 groMail: test@xyz.com gr-description: abc-location-999 ...
1
vote
2answers
43 views

Delete all words surrounded by parentheses with sed

How can I do this in sed, I have a long long list of things and some are surrounded by a parentheses. lol xml lol lol (347) idiot (67) How can delete (347) and (67) but for a huge list with numbers ...
1
vote
1answer
58 views

Replace a string in a file and overwrite the file

I wrote my script using the the directory ~/deleted (it's a long script). after using ~/deleted for the whole script. I want to let the user choose the directory by putting the path in ~/.rm.cfg. My ...
0
votes
1answer
50 views

Print lines if pattern is not matched

Print lines of File 1 only if they don't contain patterns specified in File 2 Exemple: $ cat File_1 L1 pattern1 L2 pattern pattern2 L3 pattern3 pattern L4 pattern4 $ cat File_2 ...
1
vote
3answers
43 views

Print all lines between a searched pattern of a text file to different file

I have a file called test.txt that contains: ....Request.... asaksa sda dsad dsad ....Request... 21mklk nnm212 mkmr543 849238 ....Request... 4392840 kndska 94i0-jkfjdk smdla .....Request.. 839281 ...
2
votes
2answers
66 views

Remove rows from tab delimited files based on a common column with another file

I am having trouble processing a tab delimited file based on the common column Column_4 with another file. One file is likely to be very small (less than 100 rows), the second one, however, will be ...
2
votes
5answers
153 views

extracting/copy ranges of columns from large data file

I was trying to prepare data files from one large file by extracting columns and pasting into a new file. The number of columns of the given data is very large. I want to prepare a number of data ...
4
votes
2answers
172 views

Joining two files

I have a 2 files with the following: File1.txt A 1 B 2 C 5 Z 3 File2.txt A 4 B 7 C 10 D 11 What I would like to do is create something like A 1 4 B 2 7 C 5 10 D - 11 Z 3 - Is there a ...
5
votes
4answers
206 views

How to replace m part of Lines with n part of Lines?

I have a file "test" like this: RewiteEngine On RewriteCond %{REMOTE_ADDR} !^192\.168\.1\.7$ [NC] RewriteCond %{REMOTE_ADDR} !^192\.168\.1\.8$ [NC] RewriteCond %{REMOTE_ADDR} ...