Manipulation of text by programs, scripts, etc.

learn more… | top users | synonyms

2
votes
2answers
51 views

Match missing values in text files

Referring to this question : Finding missing value in text file i have 2 files containing below data example Name Feature Marry Lecturer Marry Student Marry ...
1
vote
4answers
65 views

Sort datetime string in 12-hour format

I have a log file with contents like this: 11-12-2014 - 03:03:59AM lat = 41.990516; lon = -93.430704<br> 11-12-2014 - 03:05:15AM lat = 41.001546; lon = -93.443352<br> 11-12-2014 - ...
1
vote
2answers
28 views

Comparing value in same column and directing output to new column

I have my input file as DPortal=ECCN RemoteFile=4004_130122 0256 A02 141111 0940 29343414 11 110005 DPortal=ECCN RemoteFile=4004_130122 0256 A02 141111 2336 29843714 11 110006 DPortal=ECCN ...
1
vote
1answer
38 views

How to replace a symbol in sed only if it occurs before a letter?

In my documents, I have lots of occurences like these: [["A [["b [["8 [["c [["F [["1... What I need to do is to replace double brackets with single brackets, but only if there is a letter after a ...
8
votes
8answers
600 views

Grep for pattern at start or middle of a line

I'll start by saying that I think this problem is a little less innocent than it sounds. What I need to do: check for a folder within the PATH environment variable. It could be at the start or ...
0
votes
3answers
67 views

Reduce length of specific column in delimited text file

I need for the 5th column in a delimited text file to be reduced to just the first 5 characters. All other columns must remain unedited. Input: file1.txt column1 column2 column3 ...
3
votes
2answers
150 views

Finding missing value in text file

I have a text file with following data. Name Feature Marry Lecturer Marry Student Marry Leader Bob Lecturer Bob Student ...
3
votes
3answers
1k views

Extracting part of lines with specific pattern using awk,sed

I have a question regarding the awk/sed operators. I have a big file which has following set of lines repeated Expression loweWallrhoPhi : sum=-6.97168e-09 Expression leftWallrhoPhi : ...
1
vote
2answers
64 views

How to add a column from a file to the last column of another file using awk?

I want to add the second column of file2 to file1, that contains a number an unknown number of columns, so becoming the last column of file1. In this aim, I tried to create a file3 composed by pasting ...
-1
votes
1answer
61 views

insert comma after the last letter

I use a txt file, and I need to convert it in csv file Saint Petersburg 0 10 0.1 - N Moscow - 9 0 - N Novgorod 0 7 1 30 Y In ...
3
votes
3answers
348 views

Take the first column from 2 files and write it to a 3rd file

Suppose I have 2 Files, ABC.txt & PQR.txt with the data shown below as an example: ABC.txt: ABC DEF PQR.txt: PQR XYZ I want to grep column 1 from both files and write into a third text ...
4
votes
2answers
283 views

random permutation of lines of text

If I have a file with following content: 0001 0002 0003 0004 0132 0137 0138 0141 How can I get a random permutation of them in bash?
8
votes
2answers
339 views

How can I delete all text between nested curly brackets in a multiline text file?

This question comes from How can I delete all text between curly brackets in a multiline text file? (just the same, but without the requirements for nesting). Example: This is { {the multiline ...
3
votes
3answers
443 views

How can I delete all text between curly brackets in a multiline text file?

Example: This is { the multiline text file } that wants { to be changed } anyway. Should become: This is that wants anyway. I have found some similar threads in the forum, but they don't seem ...
0
votes
1answer
40 views

Macbook System Profiler formatted

I want to format the output generated from macbook terminal command system_profiler and transpose the row values to columns under the same Application. Here's a snippet of the file: Firefox: ...
2
votes
5answers
164 views

Re-order text on each line in a file

I'm processing a log file and I need reorder each line (not sort). The log file looks like this: 11-06-2014 - 10:49:06PM lat = 41.858657; lon = -91.345142 11-06-2014 - 10:49:49PM lat = ...
3
votes
6answers
127 views

how can I use sed to replace the lists that begins with (*) in a file

Using sed how can I replace the lines that start with a star and replace it with numbers starting from 1? I need to replace the (*) in the fist of a list with numbers using sed for example > this ...
1
vote
3answers
55 views

How do I analyze report type of data in Bash?

What is the best way to read the following data in Bash? For example if the data is like a ls -l then I could read line by line and I have all the detail of a file within a line. In this case I have ...
2
votes
4answers
147 views

Concatenate different fields with different seperator

I have a tab delimited file like this: chr1 53736473 54175786 chr1 56861276 56876438 chr1 57512145 57512200 I want to concatenate the three fields result like this: ...
3
votes
4answers
271 views

Club together N consecutive line in shell?

Let say I have a text file in this format field1a field2a field3a field1b field2b field3b I want to club 3 (or in general case N) consecutive lines, how will I do it with sed or other command line ...
2
votes
2answers
67 views

Parse several thousand lines of txt into lines and columns

The file at hand lists names, credentials, roles, and privileges for thousands of users. It was passed onto me as .xls but the lines and columns are not arranged in proper form. I have reformated ...
6
votes
8answers
742 views

How do I construct a list with numbers like this?

How do I construct a list like this: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Where I run command 15 or something. Or if I specify 100 it would make it with 100 numbers or 10000 and it would make it ...
0
votes
1answer
49 views

Replacing code between two JavaScript comments

I need to set a value of JavaScript variable from bash. Variable lives in index.html file and I'd like to use unix SED command to do that. Inside index.html I have it lake this: <script> ...
1
vote
1answer
36 views

convert row into column based on particular key

I have file like Below. But header are in different line the header Values are printed in down to the hear. I want all the header in single row & value to the Particular header to be print to ...
6
votes
5answers
622 views

Modify a file without creating another file

Is there a way to modify a file without writing the contents to other file, without sed and awk? For example, $ cat test.txt aaa aaa bbb ccc ddd Replacing using sed with -i option, sed -i ...
5
votes
2answers
336 views

delete a line if same line exists in the previous line

I want to remove lines which exist already in the previous line from the command line in UNIX. I have the following data in a file. <xref ...
2
votes
6answers
99 views

Getting the matched word exactly

I have looked through a number of question but they do not satisfactorily reply to my question. I need to print words that match the pattern exactly not the lines containing that word. For example: ...
1
vote
1answer
43 views

Need to use grep and sort for matching records and display Y and N

Input file (contain column 1 with repeat value in number and second column may contain voice,email, tel, voice mail): 123,voice 123, tel 324,voice mail 345,email 123,email Output file with headers ...
1
vote
2answers
69 views

Add certain words to a file

I am using this code to read the line number 2 from files has the same name and included in folders (the name of those folders included in list.txt): #!/bin/bash in=/au/cl/tr/129/ inlist=/1/2/3 ...
3
votes
3answers
125 views

Delta of numbers in file

On our server a cronjob has logged a count of files in a shared directory. The log is of the form: 2003-07-03T16:05 279 2003-07-03T16:10 283 2003-07-03T16:15 282 By now this file has far over a ...
0
votes
1answer
46 views

Need to compare the two files and print all the columns then missing display as NA, then join another file [duplicate]

File 1: 123, 234 345, 789 678, 900 File 2 123, abc 345, dnc output (all columns in file1 and missing value in file two as NA): 123,234,abc 345,789,dnc 678,900,NA Output file add with another ...
1
vote
3answers
265 views

using awk command to compare the two files and print all the columns then missing display as NA

File 1: 123, 234 345, 789 678, 900 File 2 123, abc 345, dnc Desired output (all columns in file1 and missing value in file two as NA): 123,234,abc 345,789,dnc 678,900,NA
0
votes
1answer
62 views

script to read certain key words in a document

I have a list of 50 folders. Inside every folder I have a text file contain key words and this file has the same name in all the folders but it has different values. How can a script read a certain ...
7
votes
7answers
466 views

How can I double the newlines in an output stream

When I have an output stream: a b c d e How can I double the newlines: a b c d e
8
votes
4answers
423 views

Remove duplicate lines from a file that contains a timestamp

This question/answer has some good solutions for deleting identical lines in a file, but won't work in my case since the otherwise duplicate lines have a timestamp. Is it possible to tell awk to ...
-1
votes
3answers
56 views

Look for numbers that is supposed to exist, but doesn't

I have a long list of numbers. Is there any way I could display the numbers that doesn't exist? In this case it would be 2 and 4 1 3 5 6 The list is in a text file. To clarify, I just have one ...
-1
votes
4answers
83 views

how to substitute some lines of one file according to the line's content [closed]

I have a file like this (this is a sample, the file contains more lines like these): first line sss case-2-hello-world other words second line other words third line sss case-1-love-you other words ...
2
votes
2answers
122 views

How to capture the port number from this `lsof -F` output using awk (or something better)?

I've got output coming from lsof -F that looks like this: p7646 g7646 R8300 csocat u1000 Labe f3 au l tIPv4 G0x80002;0x0 d640391 o0t0 PTCP n*:51352 TST=LISTEN TQR=0 TQS=0 I am trying to capture the ...
2
votes
4answers
96 views

Merging Two Files with Difference only

I have two files. file1 contains text as follows: #This Data written by the platform Team id=kingDB file2 contains the text as follows: #This Data written by the platform Team id=kiteDB,mangoDB ...
0
votes
3answers
87 views

How do I search a file for a string then use it as a variable?

I have an XML file that looks like this: <id>456</id> <root> <value>1</value> <intNum>2</intNum> </root> <root> <eulav>1</eulav> ...
0
votes
2answers
90 views

Match a whole word (IP address) using `sed`

I have the following line style in a file: 1.2.3.4 1.2.3.4a 1.2.3.45 iaa1.2.3.4ad 11.2.3.4a a1.2.3.4 1.2.3.4> <1.2.3.4> <"1.2.3.4"> 1.2.3.4 hostname I want to replace all the ip ...
1
vote
1answer
39 views

Find string in text file and execute a script depending of the result

I have a file (Data.txt) with something like this: A=1234597890 B=192.168.1.1 sometimes B goes first and sometimes only A or B. So, If I find: A, Print A content and execute A script B, ...
1
vote
2answers
68 views

Print only the second field of the second line

I have to extract from the command hcitool dev only the mac address of the BT dongle. Output of hcitool dev is Devices: hci0 xx:xx:xx:xx:xx:xx I write this output on a file and try to get the ...
1
vote
1answer
56 views

Changing text in text file [duplicate]

Is there a command line way to change text in the file? Like say I would like to change all strings "lukuunottamatta" to the form "lukuun ottamatta" and "Lukuunottamatta" to the form "Lukuun ...
1
vote
1answer
66 views

How to nest global matches with sed?

If I do: sed 's/match/replace/g' I know that sed will substitute replace for every occurrence of match on a line. But what if...? echo "match <please dont match this?>" | sed ...
1
vote
3answers
147 views

Find and delete duplicate txt files

I have a folder with around 300 text files, is there any command that reads every every file indivdually and deletes the duplicate files? I mean the content and not the file names.
4
votes
4answers
292 views

How do I show the numeric character sequence of a string?

Is there a command either standalone or in vi or similar (can be gui) that will show me the numeric sequence of a string? Input: The cat hopped in a box. Output: T h e c a t h o p p e d ...
3
votes
5answers
186 views

List files with line count and date

I want to be able to list files showing the number of lines the each file has and the date. I can happily get the line count using wc -l *. Not a problem. I can get the date using ls -l. Is there a ...
0
votes
0answers
22 views

Change encoding of a text file in-place: iconv alternative? [duplicate]

Apparently, iconv is unable to use the same file as input and output file. Other tools, e.g. sed, have an -i switch that allows "updating" a file in-place. (Under the hood, temporary files are ...
3
votes
3answers
564 views

Split the lines of a text file into separate files

I have a text file that looks something like this: foo bar zip rar tar I need to use a bash script on OSX to make a new text file after every new line like this: cat text1.txt foo cat text2.txt ...