Manipulation of text by programs, scripts, etc.

learn more… | top users | synonyms

1
vote
3answers
121 views

sed + find value before word in line

How can I find the value before the word "free"? top -n1 | grep Mem Mem: 2054968k av, 2034120k used, 20848k free, 0k shrd, 186768k buff First I tried top -n1 | grep ...
-2
votes
1answer
49 views

Extract/print every 3rd occurence of pattern

I need help with extracting/printing lines until a stop pattern. This needs to happen after every 3rd occurrence of start pattern, i.e ERROR_FILE_NOT_FOUND and continue until the end of the file. ...
3
votes
1answer
54 views

Identify duplicate blocks of text within a file

Is there a convenient way to identify duplicate or near duplicate blocks of text within a file? I want to use this for identifying code duplication. It looks like there are specialty programs with ...
3
votes
2answers
101 views

Select certain column of of each file, paste to a new file

I have 20 tab delimited files with the same number of rows. I want to select every 4th column of each file, pasted together to a new file. In the end, the new file will have 20 columns with each ...
2
votes
2answers
59 views

How to get grep exit code but print all lines?

I'd like to check whether a line printed by a command contains an error message, but I'd like to also print all the output from the command (for make logs). Is there some way to get all the output of ...
0
votes
1answer
28 views

Replace copyrights recursively [duplicate]

I have many files under the current directory. Each file contains copyrights headers like, # # Copyright 2013 Company, Inc. All rights reserved. This software # is property of Company, ...
0
votes
1answer
32 views

Why does my vim status line say “Obtaining ../”?

On the righthand side of my vim status line it says "Obtaining ../" and is highlighted yellow. Why does it say this? The results of :set are: :set --- Options --- cpoptions=BceFs history=1000 ...
1
vote
1answer
29 views

Perl one-liner for replacing values greater than a threshhold

I have a text file which contains 7 columns of floating point values (). I would like to use perl one-liner and find the values which are greater than a threshold in the 7th column. Then, I want to ...
0
votes
1answer
72 views

Very basic H/W question using pipe and grep

I have two text files, F1a.txt and F1b.txt, with essentially the same data: the driver's surname and their nationality. For example: Hamilton GBR Alonso SPA I have concatenated these ...
9
votes
2answers
502 views

Tool in unix to subtract text files? [duplicate]

I have a large file composed of text fields separated by semicolons in the form of a large table. It has been sorted. I have a smaller file composed of the same text fields. At some point, someone ...
1
vote
2answers
43 views

Extracting file name and string from multiple files

I have a lot of files (>100,000) from which I would like to extract a specific string and the filename itself. Files are organized like this: Filename: sequence.php?ID=gi|90022703|ref|YP_528530.1| ...
-1
votes
1answer
38 views

replace pattern matching

I want to replace part of a file's data, with data from another file. Suppose file1 has data as is written below and file2 has some data I want to store replace file1 data from file2 from starting ...
1
vote
3answers
55 views

Modify some files to add the file name

I have a bunch of text (hundreds of txt) inside a directory. Each of them has a unique filename. I want to insert filename of each file into the first line of respective files. How can I do that using ...
3
votes
2answers
116 views

Extract text including parens

I have some text like this: Sentence #1 (n tokens): Blah Blah Blah [... ... ...] ( #start first set here ... (other possible parens and text here) ) #end first set here (...) (...) Sentence #2 ...
6
votes
1answer
204 views

How do I print all but the Nth to last line in sed?

I'd like to do the complement / "opposite" of sed 13q;d <file.txt More generally, is it possible to do this sort of complement/inverse/opposite in sed? Or only for regexes? How do I print all ...
1
vote
3answers
46 views

Find a string in one section of a file with mutiple sections

How to sed/awk for a string contained in another string. TESTVAR=' { icon : "icons/773_l.png", id : 80, initialState : true, isPng : false, label : "Imagery", opacity : 1, requestType : ...
1
vote
3answers
191 views

“grep” the available space from “df” output

Hello I need to grep the output from df. Sadly awk is not an option (even though its the easy option) here I can only use grep. Filesystem 1K-blocks Used Available Use% Mounted on none ...
1
vote
1answer
50 views

How to Replace IP at Specific Line

I have a file (.htaccess) which contains below excerpt. <Files wp-login.php> order deny,allow deny from all allow from 45.152.35.2 </Files> I need to replace 45.152.35.2 with my current ...
0
votes
1answer
22 views

filter fileds in a file, without constant record format

I have 3 files with millions of records each. I'd like to filter those files in order to find some data more easily. Unfortunately, there is no common format from one record to other. For example: ...
1
vote
4answers
104 views

how to match the number with % from df -k command

in my bash script I want to print the use capacity of /var partition from df -k command I do the following df -k | grep var | awk '{print $5}' the problem is that sometimes "use%" number ...
0
votes
2answers
36 views

Add space after 8 characters then add space after every 4 characters

Here is the sample input: AbbigailAbieAbbyAbbi Using sed, I have separated them into 4 characters but seems like I got a problem because I have to separate the first 8 characters first then add ...
-1
votes
1answer
60 views

Match and combine records in Bash [duplicate]

Consider two csv files: $ cat given.csv 123,John 246,Paul 369,George 987,Ringo $ cat family.csv 246,McCartney 123,Lennon 987,Starr 369,Harrison Note that the lines are not ordered! How might I use ...
2
votes
5answers
124 views

Extract lines from a file containg From <str1> To <str2>

Let's says there is file "abc.txt" that contains a paragraph/lines: Hello, how are you doing sir? when are you going to arrive at the SBAHN platform to catch the train? How can I extract all the ...
2
votes
1answer
33 views

Comparing delimited fields

I have two fields in a file, students and teachers. They're delimited by a semicolon and I want to find which single students have two different teachers. jdoe;ateacher jdoe;bteacher jsmith;cteacher ...
0
votes
3answers
75 views

Combinatorics of letters and words - preferably bash, will accept perl or other [closed]

I am trying to write a shell script to generate all possible words in the English language less than 20 characters. I doubt there is any truly efficient way to do this other than to brute force some ...
0
votes
2answers
53 views

Convert two rows to two columns

I would like to convert every two rows to two columns using awk. Any help appreciated. input.txt: # Query: gi|11465907|ref|NC_001872.1| Chlamydomonas eugametos genome, complete genome # 0 hits found ...
0
votes
3answers
139 views

bash find using variable

I have an issue I don't understand. It is simple and it should work, but it doesn't. =EDITED exactly what I can see from terminal= I have a list of filenames: [molni@archlinux picasa_album]$ cat LIST ...
2
votes
3answers
105 views

Use AWK to pad date and time formats

I would like to use AWK to pad the date and time fields in my report. Here is my current .csv that is actually tab delimited. AA 9/7/2014 2:30:38 PM AA0000011111 08 Y A Jane, Doe AA ...
2
votes
2answers
20 views

Replace line names with set of new names without disturbing the rest of the file

I have a large protein sequence file where each sequence name is identified using > and the corresponding sequence in the following lines. Example (ignore quotation marks): >YAL003W EFB1 ...
-1
votes
3answers
114 views

How can I select columns based on a control file with invalid column numbers?

I have to generate the file dynamically from the source file based on the below control file. control_file.txt 1,3,5,-1,8,-1,4 The control file contains the position of columns which I require ...
6
votes
2answers
277 views

Compare two files and print matches

Is there anyway to get this through Unix shell scripting? I have a fileA with one column (1000 rows), and fileB with 26 columns(13000 rows). I need to search each value of fileA with fileB and return ...
1
vote
0answers
27 views

Create files from templates, substitutions in middle of other words

Is there a way to convince m4 to replace a macro in the middle of a word? I would like this file, day.m4: define(Sat,Cat)dnl Saturday and this command: m4 day.m4 to produce this output: ...
2
votes
3answers
46 views

Merging two tables including multiple ocurrence of column identifiers and unique lines

I asked a similar question yesterday (Merging two tables including multiple ocurrence of column identifiers) but ran into a problem with unique lines. I would like to merge two tables based on column ...
1
vote
3answers
49 views

Replace word instances with its count attached to it

I have a file which contains word 'name' multiple times ( 250 times ). I need to replace every instance of 'name' with its count attached to it as name_1, name_2, name_3....name_250. Can I do this ...
4
votes
6answers
157 views

Sed — Replace first k instances of a word in the file

I want to replace only the first k instances of a word. How can I do this? Eg. Say file foo.txt contains 100 instances occurrences of word 'linux' . I need to replace first 50 occurrences only.
2
votes
2answers
105 views

Merging two tables including multiple ocurrence of column identifiers

I would like to merge two tables: File 1: 1 today 2 tomorrow 3 red File 2: 1 a lot 1 sometimes 2 at work 2 at home 2 sometimes 3 new Desired output (file 3): 1 today ...
1
vote
2answers
61 views

Count the maximum character length for all the data fields in a csv file and output to txt

Given a CSV with many data fields (>50), how can I count the maximum character length for each data field and then export all the counts to a txt file? BTW, I want to ignore the first line of the file ...
0
votes
0answers
24 views

Shell Script for tracking number of times each command executes

How to have a shell script that takes input from /var/log/sudo.log and sends results to a spreadsheet that displays graph for each command execution? I want to record how many times each command ...
0
votes
2answers
27 views

How to find the occurrence of names in a file?

I want to know how many times users who have logged on the system in a single command. I have used repetitive commands to find the how many times he have logged. $ last | grep -c user1 $ last | grep ...
1
vote
3answers
46 views

sed match pattern N times

I want to split a file into chunks with 2 words each. $cat tmp word1 word2 word3 word4 word5 word6 word7 $sed -e 's/word. word. /&\n/g' tmp word1 word2 word3 word4 word5 word6 word7 $sed -e ...
1
vote
1answer
46 views

Use case for /usr/bin/lessecho

I can not come up with an example of how I could/would use lessecho. The description in the man page is fairly straight forward but is not helping me come up with a use case: DESCRIPTION ...
1
vote
4answers
165 views

Decimal conversion number of the form x.xx to 0x.xx, sed?

I have a file of the form ... num 0.12 num num num 25.53 num num num 7.82 num num ... and I want to convert the 2nd field of each line adding a "0" at the numbers >= 0 and < 10 so the output ...
-2
votes
1answer
40 views

Place the cut field in the desired position of ouput file [closed]

I am writing a script like in which, it will cut the fields from input file and append to output file. cat $1|while read line do acc_no=`echo "$line" | cut -c29-43` acc_type=`echo "$line"|cut ...
-1
votes
1answer
37 views

convert scientific data into generic

I have a file containing only numerical values in scientific format. I want to convert them into generic notation and multiply them by 1000. e.g. input.txt 1.1234e-01 2.123e+01 3.12345e-02 ... ...
1
vote
1answer
48 views

Store output from one command and process it for another

I am working on Unix command line. I have two files. I want to cat file1.txt and grep the output in file2.txt File1.txt 123A 223A 143A 153A 183A 123J 123P File2.txt: 123A (TYU) 223A (RUT) 143A ...
1
vote
4answers
61 views

Parsing complex text file using Unix commands

I have the following text structure which I would like to parse: >Cluster 423 0 56aa, >HWI-ST1448:257:C3V2HACXX:1:1106:19087:2550.1... at 92.86% 1 64aa, ...
2
votes
3answers
72 views

how to concatenate a file with multiple header into one

Can you suggest me how I can combine. a.fasta with 10000 sequences having headers 1, 2, 3, .... 10000 .......................into just one header e.g >1 AAATTTTGGGGCCC >2 ACCCCGGGTTT ...
2
votes
0answers
20 views

Make GNU indent break long comments

Is there a way to convince GNU indent to break long comment and change it to multiline comment? Something like this: // Very long comment, longer than 80 characters. Just imagine that. To this: /* ...
3
votes
2answers
196 views

awk: Extracting a fixed number of rows where the last row number may vary

This question may look like a duplicate, but only at first glance. Of course, I would no longer need help in how to code a one-liner that extracts a fixed number of continuous lines (e. g. 5 in this ...
1
vote
3answers
70 views

Print content of file from desired character and end also to desired character

I have this file with content written below. I want output of my file stating with ".SUBCKT C032_THS_COMPARATOR" and end with ".ENDS": .SUBCKT C032_THS_DPDNPROT_cdm_tdpdnw TOPROTECT VPLUS .SUBCKT ...