Manipulation of text by programs, scripts, etc.

learn more… | top users | synonyms

1
vote
1answer
45 views

Why don't the SHA's match?

I am trying to write a script and it uses the SHA of a date but I am getting two different results and for the life of me can't figure out why. echo -n 03112016 | cut -d'.' -f4 | sha256sum | cut -d' ...
3
votes
3answers
36 views

Strings - Extract File Version Recursive

I have been using strings to extract and compare file versions between directories. I don't seem to be able to do this recursively. The method I have been using per file is: strings -e l ...
-1
votes
3answers
65 views

Better way to parse string with bash?

I need to parse the below command to extract namespace & interface names using a bash script. I generally do this using IFS, but that seems tedious to me. Is there a better way of doing this ...
-1
votes
2answers
35 views

First and last five lines of file [duplicate]

How to see first and last 5 lines of file? Right now I am using head filename ; tail filename Any other way around and more efficient?
1
vote
4answers
52 views

Remove any occurrence of '-' from a field in shell script

below is my csv file,I want to remove all occurrences of - from retailer_id field and create new csv. Kindly help... ...
0
votes
2answers
49 views

Compare a file with a column of another file

I have a file File1 with data as aaa bbb And another file File2 with data as: 2,aaa,234 w,bbb,589 4,ccc,675 I need to compare the File1 data with column2 data of File2 and print the matching ...
0
votes
3answers
54 views

Awk command is not working properly

I have a very simple problem, but for reasons it does not work properly.. I have these .txt files in the following format 2 250 1 4 250 1 5 250 1 I wanted to subtract 1 from the ...
-1
votes
3answers
70 views

Change all values with an absolute value less than 1 with 0

I have a large file with a lot of rows and columns; the value of the contents are between -2 and 2. I'm interested in replacing values which, in their absolute value form, are less than; I want to ...
3
votes
5answers
69 views

How to extract data from a file and construct a filename from one of the values

I'm trying to pull two values from a configuration file and write them to a new file. The hard part is that I want the name of the new file to be determined by one of the values in the input file. ...
1
vote
2answers
35 views

Joining columns from files if they contain a match in another column

I have two files: File1.txt 30 40 A T match1 string1 45 65 G R match2 string2 50 78 C Y match3 string3 File2.txt match1 60 add1 50 add2 ...
3
votes
6answers
169 views

Add quotes and new delimiter around space delimited words

I have the following string y10_zcis y10_nom y10_infl y20_zcis y20_infl y30_zcis I would like to transform this to "y10_zcis", "y10_nom", "y10_infl", "y20_zcis", "y20_infl", "y30_zcis" I ...
1
vote
1answer
44 views

How to test if certain strings existing in file are present in another file?

I have a file sites.txt that is generated by a script. It's a list of host names. I have another list of host names sites_old.txt. I need to check whether any of the host names present in the ...
1
vote
2answers
34 views

Reorganizing lines in a text file

So I have the following file: First Line Second Line Third Line 3 0.374 2 0.777 1 0.245 Fourth Line 4 0.687 ... And I want to reorganize it so the lines beginning with an int are appended to the ...
0
votes
4answers
40 views

Difference between open file & open STDIN, when to use each [duplicate]

In very lot of answers, mainly about text-processing commands, I saw commands such as sed, awk, grep, among other, being used with STDIN and the simple open of a file e.g. $ sed -e 's|foo|bar|g' ...
0
votes
3answers
40 views

I want to manipulate the group file entries [closed]

Suppose I have a file: uid=1(a) groups=cat,dog,hen uid=2(b) groups=cat,hen uid=3(c) groups=hen uid=4(d) groups=dog,hen,buffalo,horse I am looking for: cat a,b dog a,d hen a,b,c,d buffalo d horse d ...
1
vote
0answers
52 views

how to copy a piece of a text file byte-by-byte to another text file? dd, head, or?

I need to grab the first lines of a long text file for some bugfixing on a smaller file (a Python script does not digest the large text file as intended). However, for the bugfixing to make any sense, ...
3
votes
3answers
363 views

does head input > output copy all invisible characters to the new file?

I need to grab the first lines of a long text file for some bugfixing on a smaller file (a Python script does not digest the large text file as intended). However, for the bugfixing to make any sense, ...
-1
votes
1answer
42 views

In a text file how can I sed multiple portions of text bordered by specific text patterns of text on Unix?

I use sed -n START_LINE,FINISH_LINEp filename > newfile to extract a specified range of text from a text file, e.g. sed -n 45,50p datafile > newfile. How can I use this to extract multiple ...
0
votes
1answer
18 views

Add data lines file 2 to file 1 without header

Here is my data: File1 Cow_ID Age DIM MY MCF MCP MCL BW BCS 1 1424 0 NA NA 0.0336 0.0505 NA 4.25 File 2: Cow_ID Age DIM MY MCF MCP MCL BW BCS 2 1424 0 NA NA 0.0336 ...
0
votes
1answer
32 views

Subset rows with awk [duplicate]

I am new to Linux, but my work requires me to do some specific task now, I hope you please help me for this. I have a data set as follow: Cow_ID Age DIM 1 1424 0 1 1425 1 1 1426 2 1 ...
6
votes
4answers
365 views

How can I use grep to display lines WITHOUT either of two specific strings?

For a large logging file, how do I display those lines without "success" or not terminated with "ok"?
0
votes
2answers
29 views

placing words corresponding to a key in a singe row

I have a symbol table of the form (key-value pairs) 01 aaluu desii 01 aaluu cipsa 01 amaruuda ilaahabaadii 02 hai 02 nahii 02 txamaatxara To start with, I am supposed to place ...
0
votes
1answer
57 views

Parsing text file using awk

I have a continuously changing text file that contains messages from the Gmail API. I need to parse the contents of it. My text file contains the id of the message, the message, sender details and the ...
1
vote
4answers
61 views

How to use printf with awk to designate the columns separated command output

I want to extract the manufacturer name, card's firmware version and status from the output of fcinfo hba-port, which looks like: root-#> fcinfo hba-port HBA Port WWN: 10000000c96a53c5 OS ...
2
votes
2answers
41 views

How to find/grep what is between string1 and string2?

I am trying to extract a value from a long string that may change over time. So for example the string could look something like this ....../filename-1.9.0.3.tar.gz"<.... And what I want to ...
1
vote
3answers
44 views

replace a string 6 line after matching string

I want to change notification_interval from 15 to 2 for block File_Check only. I tried changing line 6th after matching File_Check line with: sed -e '6 /File_Check/ s/15/2/g' file.txt but it did ...
2
votes
1answer
38 views

awk matching only 1 lines with same pattern

The following awk script will add an entry SAMPLE to block NOTES. I have multiple blocks with the same name. What needs to be changed in this command to add the entry SAMPLE to first block NOTES only? ...
1
vote
1answer
41 views

Multiline(in one paragraph) pattern replace use awk or sed

$cat test.txt blablabla ```{r} blabla ``` blablabla blablabla blablabla ```{r} blablabla blablabla imname <- "FIGNAME1" saveflag <- savepdf(imname) ``` ```{r} blablabla blablabla imname ...
0
votes
1answer
73 views

Is there any method to edit a text file without opening it? [duplicate]

I have a text file which has about 70000000 lines in Linux system. How to delete the lines from 40000000 to 50000000 without opening the file? Thanks.
0
votes
1answer
30 views

How to replace word in specific column if it does not match an expression?

I have the following file: chr1 157784 157887 U6 0 - chr1 564813 564881 miRNA 0 + chr1 564879 564950 tRNA 0 - chr1 564952 565019 tRNA 0 + chr1 566062 566129 ...
0
votes
0answers
25 views

compare two text files and extract different lines [duplicate]

I have two text files. I want to compare them and extract different lines. for example. a.txt looks like this: a b c d e f b.txt: c f d I want to compare these two text files and output ...
1
vote
4answers
55 views

Bash script to read two specific lines from text file and use parts of them as variable

So i got a text file which looks like this # begin build properties # autogenerated by buildinfo.sh ro.build.id=LRX21T ro.build.version.incremental=G900FXXU1BOK6 ro.build.version.sdk=21 ...
6
votes
3answers
229 views

How can I display 3 lines of text at a time onto 1 line?

I have a log file that displays data 3 lines at a time. Like this: 1 data 2 data 3 data 1 data 2 data 3 data 1 data 2 data 3 data I'd like to take each 3 lines and ...
1
vote
1answer
29 views

sorting on two vertical columns

I have a file that I want to sort from the nth column (which is numeric) - not the nth field. The file looks schematically like: 1 Here are four words 9 8 5 2 Here's two 7 2 6 ...
-2
votes
1answer
71 views

How to use grep and cut paste to extract information by feature type in UNIX [closed]

I have this assignment that is supposed to be challenging. I have been stuck on it for about 20 hours. I would like help as I am confused in how to get the information that my professor wants. ...
3
votes
2answers
119 views

How to extract several data from a file and store it in a csv file?

I have a file in the following format : 19-08-02 Name appel ok hope local merge (mk) juin nov sept ...
1
vote
2answers
33 views

Effective way of changing the format of numeric file data

So I have a big file containing the values of a matrix with the folowing format: (0,0) 0.6666 (0,1) 0.0000 (0,2) 1.3333 ... And I want to convert it to: 0 0 0.6666e+00 0 1 0.0000e+00 0 2 ...
3
votes
3answers
51 views

I want to grep out a text string from many files, how can I run a loop for this

I have a thousand .xyz files, all numerical data and in the same directory. Some of them have the text string "END" at the very end of them. I'm not sure how to loop a grep command so that it removes ...
0
votes
3answers
44 views

Increase integer in string by 1 for each line

with for example sed, awk or python. there will be 548 lines in the original txt file from this: http://twit.cachefly.net/audio/sn/sn0001/sn0001.mp3 ...
2
votes
3answers
58 views

Suppress filename from output of sha512sum

Maybe it is a trivial question, but in the man page I didn't find something useful. I am using Ubuntu and bash. The normal output for sha512sum testfile is <hash_code> testfile How to ...
0
votes
0answers
34 views

Parse iostat and print selected stats

The below is my statistics: [gpadmin@GP-MASTER]$ iostat -t -c Linux 3.8.13-16.2.1.el6uek.x86_64 (GP-MASTER) 02/25/2016 _x86_64_ (1 CPU) 02/25/2016 10:44:59 AM avg-cpu: %user %nice ...
0
votes
1answer
52 views

Shell program that outputs the averages

Basically, what I need to do is write a shell program called avgs that would read lines from the file with data, where the title line could be at any line within the data. Hint: You must keep a total ...
1
vote
2answers
46 views

Swapping the first two word of every line without using sed

I want to know if there is a way to easier way to swap the first two words of every line. Let say my text file consist of these three lines: Mary Joe William Edward Shawn Liam Ultimately I ...
4
votes
3answers
116 views

Delete consecutive lines in CSV with duplicate values in one field, but keep the last line

I have a long CSV file with two columns, which includes runs of consecutive duplicates like this: ... 1500,1533 1554,1678 1554,1703 1554,1728 1593,1766 ... I need to delete all of these duplicates ...
1
vote
3answers
30 views

How can I parse JSON to test the string value of a nested key?

For example, here is my program's output (bspwm, if you wanted to know): { "id": 29360131, "splitType": "vertical", "splitRatio": 0.5, "birthRotation": 90, "vacant": true, "sticky": ...
0
votes
4answers
51 views

Extract ranges of lines from a file, saving each range to a separate file

I have a file that looks like this 740*02/01/2016*00:00* EJ LOG COPIED OK AUTO INIT COPY DRIVE NOT CONFIGURED E1EF3901 [020t*741*02/01/2016*05:45* *TRANSACTION STARTED* [020t CARD INSERTED ...
1
vote
2answers
120 views

Append line to a block of text incrementing the value from previous line

I have a text file name class.txt with follow contents. [serverClass:MAIL] whitelist.0=LATE whitelist.1=ONTIME [serverClass:LETTER] whitelist.0=FIRST whitelist.1=SECOND whitelist.2=THIRD ...
1
vote
2answers
39 views

Align command output in columns

I have the following output of my script: panos@panos:~/scripts> ./list_packages openSUSE-2016-254 zypper-aptitude.noarch : 1.12.23-1.1 update needed zypper-log.noarch : 1.12.23-1.1 update needed ...
0
votes
3answers
69 views

Count all lines between a delimiter

I want to count the number of addresses attached to each device in the below example. Preferably using awk or sed. /dev/1 addr1 sometext sometext sometext addr2 sometext sometext sometext addr3 ...
0
votes
1answer
36 views

How can I replace rows containing ONLY number ' 0' with blank rows using AWK?

I am new to AWK, I am looking for a command that would replace the rows containing ONLY number 0 in their columns, with 'blank' lines. e.g. I have below input: Taj_Mahal ...