Manipulation of text by programs, scripts, etc.
1
vote
1answer
18 views
How to change trailing numbers to incrementing number
I'm using ArchLinux 4.1.6-1 and bash 4.3.
I need to tidy up a pile of programs in 200+ industrial robots and so trying to automate the leg work.
I can strip a file down to a just a list of ...
1
vote
1answer
47 views
AIX Non GNU tool for text replacement
Contents of the file :
PS1="$(hostname):${LOGNAME}:\${PWD} ${PROMPT} "
PS1="${FGOLD}$(hostname):${LOGNAME}:\${PWD} ${PROMPT} ${NORMAL}"
PS1=abd
PS1="$(hostname):$LOGNAME:\$PWD $PROMPT "
export PS1 ...
1
vote
1answer
20 views
Convert old DNS zone file into new format
I've got this old domain zone file with this format
ZZYZX IN NS DNS1.NAME-SERVICES.COM.
IN NS DNS2.NAME-SERVICES.COM.
IN NS DNS3.NAME-SERVICES.COM.
IN NS ...
-2
votes
3answers
35 views
I only want part of the sentence. Is it posible to cut from the start to the end and only get the output i want?
My file:
<TextBlock x:Key="applicationNameSpectrumAnalyzer" Text="Booting Spectrum Analyzer"></TextBlock>
<TextBlock x:Key="applicationNamePowerMeter" Text="Booting Power ...
4
votes
2answers
55 views
How does grep decide that a file is binary?
I have a large utf-8 text file which I frequently search with grep. Recently grep began reporting that it was a binary file. I can continue to search it with grep -a, but I was wondering what change ...
1
vote
1answer
20 views
Modify string if original does not match particular string
I have a file with millions of rows and want to modify values in column A only if the string is '.'. The modification would be to add "chr:"$2":"$3 to the start of the string. All other rows would be ...
1
vote
3answers
40 views
Grep for multiple strings, show number of lines after one of the strings (but not the other)
As the title suggests, I would like to search a file for multiple strings and for one particular string, show the 5 lines following it as well.
cat file | grep -e 'string1' -e 'string2'
works of ...
1
vote
1answer
21 views
How to remove a line from a tag in shell script?
We have an xml file (abc_lop.xml) in which I need to remove a line which is present in a tag:
Below is an xml file, I have shorten it down as it is very big.
<HELLO version="4.2" ...
0
votes
2answers
43 views
Replace all occurrences of a string found in a file using values from another file
I have a CSV file (data.csv) as below:
apple_val, balloon_val, cherry_val, dog_val
1 ,5 ,6 ,7
3 ,19 ,2 ,3
I have a text file (sentence.txt) as ...
1
vote
3answers
41 views
parse credentials from PHP configuration file
I'd like to write bash script to parse data from a configuration file. I searched for this but without finding something I could modify to suit my needs.
Joomla! config file:
public $access = ...
1
vote
2answers
32 views
Cut every 100th column from csv
I have a data file of numbers seperated by tabs, like this
1 2 3 4
2 4 6 8
My real file is 50000 columns wide and I only need every 100th column (column 100, 200, 300, 400, ...).
Now I would like ...
3
votes
2answers
45 views
Keeping first instance of duplicates
I have a file with multiple columns and have identified lines where specific column values (cols 3-6) have been duplicated using a bash script.
Example input:
A B C D E F G
1 2 T TACA A 3 2 Q
3 4 I ...
-1
votes
1answer
22 views
Get the respective tablenames if it matches particular pattern
I need to list the table names if it finds particular pattern from the below file.
CREATE TABLE IMS.ACTIVITY (
"ID" INTEGER NOT NULL ,
OWNING_TYPE FOR COLUMN OWNIN00001 VARCHAR(20) ...
0
votes
1answer
49 views
Split a set of data to massives and find maximum for each
I have a set of data looking like this:
1 0.1
2 0.23
3 0.05
5 0.73
6 0.40
7 0.34
10 0.11
11 0.45
12 0.68
I need to split the set of data to massives using the rule that the next ...
1
vote
2answers
24 views
Saving data between names in terminal to new files?
I have the following text file:
(Employee Ashley)
insert text here
(Employee Bob)
insert text here
(Employee Joseph)
insert text here
I would like to take the text for each "employee" and ...
2
votes
5answers
80 views
compare data in two files one has 2 column while other has 3 column
I have two files:
File 1:
Chromosome Position
Chr1 5242097
Chr1 4876397
Chr1 9474943
Chr1 8494518
Chr1 39872693
Chr1 9445153
Chr1 23044399
Chr1 8018859
Chr1 9474943
Chr1 ...
1
vote
3answers
41 views
how to extract a value from a string in xml using grep or awk in Linux
I have a file containing:
DEVICE="7" PGMNR="24" VCONF="800"
In this file, I want to find PGMNR="24" and I need the value 24 without the ".
The PGMNR="24" may be located anywhere in the line.
The ...
1
vote
4answers
62 views
Getting different parts of a line
Suppose I have a line of text as follows:
I have a nice car
Is there any way to get different words of the line at different positions individually (say, I want to get 'have' and 'nice' parts) ...
4
votes
3answers
186 views
sed, convert single backslash to double backslash
I have a json string, which has a potpourri of doubly escaped/singly escaped newline chars. Json parser doesn't allow its string value to have single backslash escapes.
I need to uniformly make all ...
1
vote
0answers
28 views
Join gets stuck on 10000
I'm trying to merge two files that share the first column.
The problem is that join seems to get stuck on 10000:
join: jobs.base:9986: is not sorted: 10000 4315042
join: ...
2
votes
4answers
30 views
slicing different words from output
Suppose, the result of a command in linux shell is as follows:
X and Y are friends
Is there any way to slice each of the words (X, and, Y, are, friends) or the first n words from the result, so ...
0
votes
0answers
35 views
using shell script to display a paragraph from a pdf file [closed]
In the reference section of a research paper(in pdf form), many other paper names are cited which have been used inside the pdf at different places. If I give an input, the name of a paper which has ...
1
vote
1answer
45 views
Rearrange the filecontent in UNIX
I need your help on this... need to re-arrange this:
----------------------------------------------------------------
- Partition Name: testblade012 -
- Type: ...
-1
votes
1answer
34 views
Replace a string with “string|string”
I have a pretty weird problem. I did some calculations for bioinformatics, but my downstream apps won't accept my header information in its current format. In order to circumvent this I modified my ...
0
votes
0answers
52 views
Arrange data in columns
I have a big data.txt file like this:
6712,04444
6712,02344
6712,02220
6712,02233
5322,00040
5322,02230
5322,42002
4444,03342
4444,03323
11,42023
11,00000
11,23443
11,23232
and then I want to make ...
-1
votes
1answer
32 views
getting the pattern from file
I have a text file in the below format. I want to pick one instance each time(line ABC to MNR) and work on the respective lines and columns. Need help to achieve that.
ABC 12 20150911 121 005 001
...
2
votes
1answer
23 views
Add/Append a column as first column to a tab delimited file
I have a Tab separated file as follows:
A B
HM 1
BN 2
I would like to add another column to this file such that this new column becomes the first column of the file as shown below:
...
1
vote
3answers
44 views
Replace arbitrary characters in the middle of an IP address string with sed
I need to find and replace either one or two numerical characters in strings in a file. The strings are IP addresses of the form:
10.xx.y.z
Where xx can be one or two characters.
I want to ...
0
votes
2answers
26 views
How to get the sed command to only search for full words?
I'm fairly new to Linux and recently started experimenting with the command line. I decided to make a file and called it 'hi.txt'. The contents of the document was:
This is hi.txt.
hi
hi
hi
I ...
1
vote
3answers
41 views
how to remove first occurrence of 0 in mm/dd a date using sed?
I want to remove first occurrence of 0 in mm/dd, e.g. I want to make 09/09/15 look like 9/9/15.
I have tried using echo 09/10/15 | sed 's/^.//' but it gives output like 9/09/15. How can I do this?
0
votes
2answers
15 views
How can I reformat a time string in multiple files?
I have files which has the following lines
15.07.2015 12:24:47; +107.117 ; +106.925 ; +17.179 ; +102.099 ; +16.151
The first is the time stamp in a non standard format, how can I replace it inline ...
1
vote
4answers
67 views
sed - Print lines matched by a pattern range if one line matches a condition [duplicate]
I have a multi line log entry format that I need to process.
The log looks something like this:
--START--
Device=B
Data=asdfasdf
Lorem=Ipsum
--END--
--START--
Device=A
Data=asdfasdf
Lorem=Ipsum
...
0
votes
2answers
29 views
Given a string to match in a file how to output the specific line(s) which doesn't occur at a specific distance from the matched string?
The title doesn't grasp the body much. Edits are requested.
I've a string android.permission.CAMERA to match in the output of adb shell dumpsys package. My goal is to list the package name of the ...
2
votes
6answers
64 views
uncommenting specific code in a larger file
I have these lines of code in my /etc/bash.bashrc file in Ubuntu 15.
How can I uncomment only those lines from the command line, without without messing up any other comments in the file?
# enable ...
4
votes
1answer
46 views
How to make tr aware of non-ascii(unicode) characters?
I'm trying to remove some characters from file(UTF-8). I'm using tr for this purpose:
tr -cs '[[:alpha:][:space:]]' ' ' <testdata.dat
File contains some foreign characters (like "Латвийская" ...
10
votes
5answers
650 views
head, tail, and then line? [duplicate]
What is the simplest way to extract from a file a line given by its number. E.g., I want the 666th line of somefile. How would you do this in your terminal, or in a shell script?
I can see solutions ...
4
votes
3answers
257 views
Convert genotypes to 0/1
I have a file that looks like:
1 rs6687776 1020428 T C T C T C C C T C C C T C
The 4th and 5th column are the two different possible alleles at that ...
0
votes
4answers
73 views
How to delete the newline before EOF in a text/csv file via bash
Below is an example of the data I'm receiving in txt or csv file (seen in EmEditor):
However, the final blank line is causing problems when uploading this data into my software. I need to have the ...
1
vote
1answer
83 views
How to extract unique values within columns
I have a data file with 10,000 columns and 117,000 rows. my original data has a lot of repetition within each columns. it is like:
inputfile.txt :
123 124 111
321 124 111
123 000 111
...
-1
votes
3answers
59 views
find most frequently occurring letter/character combinations in a file
find most frequently occurring letter/character combinations in a file
Instead of just looking for recurring words (a la: find n most frequent words in a file), I need to list all recurring letter ...
1
vote
2answers
49 views
Print the first and last match of a field with awk
I have a tab delimited file:
qrs John tuv
abcd Sam efgh
ijk Sam lmnp
abcd Sam efgh
ijk Sam lmnp
qrs John tuv
I am trying to print the line in which the ...
3
votes
5answers
162 views
Find text between tab (\t) as a delimiter
I thought this will be simple, but can't find out how to do it.
Scenario
I have a single .csv file with id_user,text,id_group columns where each column is delimited by tabs such like:
"123456789" ...
1
vote
2answers
27 views
Split file in two on line before pattern
This is an almost identical question to split file into two parts, at a pattern but instead of having the lines up to XYZ in file1 in the example file.txt:
ABC
EFG
XYZ
HIJ
KNL
I want to have the ...
1
vote
2answers
31 views
Select file based on number of lines and manipulate the result
I have a large number of files, all with the same format.
line 1: Gene ID
line 2: chromosomal position
line 3 - x: names of genetic variants)
I want to select only files containing at least 5 ...
6
votes
1answer
133 views
Handling 3 Files using awk
Consider following files:
file1:
boo,8,1024
foo,7,2048
file2:
foo,0,24,154
noo,0,10,561
file3:
24,154,7,1024,0
What I need is to go to File1 and check if $2==7; if true, take $1, $2 and $3 ...
0
votes
1answer
35 views
How to find maximum number of different strings?
I have a file:
2.0-00-04
2.0-00-03
2.0-00-02
2.0-00-01
2.0-00-00
1.0-00-02
1.0-00-01
1.0-00-00
How can I find maximum number of each group? In the string above, output should be:
2.0-00-04
...
0
votes
0answers
19 views
Properly sorting a csv file [duplicate]
The sort function looked promising, but as far as I know, it can't handle escaped line feeds, and the field deliminator option -t doesn't have an option that will take into account escaped commas.
...
0
votes
1answer
26 views
Print specific FULL column only by range
I have a file which have contents like this.
Column1 Column2 Column3 Column4
USER1 25 Years xyz zyz 123 abc
...
0
votes
1answer
34 views
Sed command with complex pattern and replacement
I have the following two strings saved as variables:
str1='ds-cfg-global-aci: (targetcontrol="2.16.840.1.113730.3.4.2 || 2.16.840.1.113730.3.4.17 || 2.16.840.1.113730.3.4.19 || ...
0
votes
2answers
26 views
Merge labels from lines with duplicate fields
I have a rather large text file(thousands of lines) in following format:
123.123 5
123.123 91
156.456 45
233.185 85
233.185 4
257.448 1
455.456 60
455.456 2
The first column are ...