Manipulation of text by programs, scripts, etc.
8
votes
7answers
920 views
Combining 2 different cut outputs in a single command?
I have a file such as the following:
1234
ABCD
EFGH
I'd like to convert it to the following:
2341
BCDA
FGHE
The actual file has 4,000 words, so I would like to do this in an efficient manner. I ...
1
vote
2answers
30 views
how to select, copy columns of different file to form new files
I have four files each contain daily station data.
file 1: prec
file 2: minT
file 3: maxT
file 4: wind
Here prec, minT, maxT and wind are files that store values of prec, minT, maxT and wind for ...
11
votes
6answers
9k views
combine text files column-wise
I have two text files. The first one has content:
Languages
Recursively enumerable
Regular
while the second one has content:
Minimal automaton
Turing machine
Finite
I want to combine them into ...
4
votes
1answer
63 views
Looking for lines which is in one file but not in other using Unix and Awk
I have 2 files with 7 fields and I want to print the lines which are present in file1 but not in file2 based on field1 and field2.
Logic: I want to print all the lines, where there is a particular ...
2
votes
3answers
72 views
changing column separators in a file
I have a large file, that I need to process and after writing some scripts that don't seem to work properly, I have discovered that a small subset of the lines in the file are actually space separated ...
14
votes
9answers
19k views
How to count the number of a specific character in each line?
I was wondering how to count the number of a specific character in each line by some text processing utilities?
For example, to count " in each line of the following text
"hello!"
Thank you!
The ...
3
votes
1answer
146 views
Advanced Find and Replace Program
I have code in which I need to do a mass find and replace (within only one file).
I could easily do this except for that I need a free program (Preferably already compiled for Ubuntu so I don't have ...
3
votes
2answers
193 views
Limit stdout from a continuously running process
I haven't had much luck finding an answer to my problem, but maybe I'm not asking for it correctly.
I have a process I startup like the following:
nohup ping 127.0.0.1 > log.txt >2>&1 &
...
4
votes
3answers
81 views
Grouped sorting of continuous paragraphs (separated by blank line)?
I think I'm pretty experienced now in sorting by columns; however, I haven't found anything so far how to sort continuous rows.
Supposing we have a text file that looks like this: (very simplified, ...
2
votes
2answers
73 views
How to grep the last number on a line in a bash script
I have output from the smartctl -a command; one of the lines looks like this:
9 Power_On_Hours 0x0032 100 100 000 Old_age Always - 301
I've placed this into a variable (if that's the correct term) ...
3
votes
2answers
75 views
Easily get a particular column from output without sed or awk
Is there a quicker way of getting a couple of column of values than futzing with sed and awk?
For instance, if I have the output of ls -hal / and I want to just get the file and directory names and ...
0
votes
1answer
45 views
Removing lines based on tags for different files and merging into single file
I have to develope unix script in such way it should meet below scenario.
I have 3 text files, 1.txt , 2.txt and 3.txt
Data in those files as below.
HDR|1|2|3|||||||||||||||||||||||
...
4
votes
1answer
80 views
Sorting a file based on one column using Unix and Awk
I need to sort the input file according the 6th column, which is the score.
Input File:
Sc2/80 20 . A T 86 Pass N=2 F=5;U=4
Sc2/80 20 . A C 80 Pass N=2 F=5;U=4
Sc2/60 55 . G T 90 Pass N=2 F=5;U=4
...
3
votes
2answers
79 views
tac command's option creates strange output [comprehension question]
Say I have this file, containing nothing but
a
b
c
b
a
Using tac --separator=a file in BASH [on a Debian based Linux], I get this:
# empty line
# empty line
b
c
...
1
vote
2answers
52 views
Remove complete line in text files based on Tags
For example :
01.txt, 02.txt, 03.txt and 04.txt has following values.
HDR|A|B|C|D|F|||||||
DTL|1|2|3|4|5|||||||||||
DTL|5|6|7|8|9|||||||||||
TLR|A|B|C|D|F|||||||
I have to remove complete lines ...