Manipulation of text by programs, scripts, etc.

learn more… | top users | synonyms

-3
votes
2answers
38 views

add a row from a file into another file as row

I have file1 whose content is like this : The 6 columns are obtained from 6 different hosts before presenting them using "-exec cp" command. This is just FYI. Now, I have a list of 6 hostnames (...
1
vote
2answers
77 views

Print text between multi-line delimiters

I am trying to extract data between 2 matching patterns, only if the content is not empty and I have issues doing it: here is an example: ============================== Queue Manager is : ...
2
votes
1answer
31 views

How can I put this string manipulation in a loop so it continues until there's nothing left to do?

I am creating a script to strip off all parts of a url other than "domain.com". I've managed to get most off, but I'm running into a problem with subfolders. Here is my code: domain=$1 inp="${domain/...
6
votes
1answer
44 views

How to display dependencies given in a makefile as a tree?

Problem I want to see the dependencies for one or more targets of a makefile. So I am looking for a program that can parse makefiles and then will represent the dependencies in some tree-like format (...
4
votes
4answers
454 views

Print only the Nth line before each line that matches a pattern

I'm trying to print only the <N>th line before a search pattern. grep -B<N> prints all the <N> lines before the search pattern. I saw the awk code here that can print only the <N&...
1
vote
3answers
47 views

How can I use string manipulation to detect and remove two different parts of a string?

I'm making a script that will remove the http:// or https:// from a URL. So far I've got it to remove the http://, but I can't seem to figure out how to modify it so that it will remove either that ...
1
vote
1answer
45 views

Replacing mysql settings with sed

I am creating a backup web server but I want the backup server to only have one root user. So after moving all the databases I need to replace all the mysqli_connect(...) lines in db.txt. I have ...
2
votes
1answer
34 views

How to get a list to be entered in quotes

firstly I am a total n00b with scripting, so please forgive any incorrect terminology. I have a simple script that runs a python script (used to deduplicate emails via IMAP) after a user has entered ...
-3
votes
2answers
47 views

linux + convert file format columns to one column

I have the following file (Linux.txt) linux-test01 linuxER LinuxCV LinuxWE LinuxPL LinuxDF LinuxXC LinuxSD LinuxAQ how to print using awk or perl one-liner to produce the following ...
1
vote
4answers
84 views

Impose character between repeated characters

Given a string of characters ,,a,,,b,,,, I want to impose the character - at the beginning, if no character is preceded comma, and between every comma that has no character. Meaning the result is -,-,...
1
vote
2answers
59 views

Process several files and print filename without extension and the value of a specific key

I have ASCII file and I want to output the file name and a specific field from this file beside each other. For example: The contents of the ASCII file "data1.txt" is as follow: Name: John Age: 90 ...
3
votes
1answer
32 views

Awk Search - Combined Character Classes in Same String

Good Evening, I am attempting to utilize multiple character classes at the same time without success. Given a column that contains the URI of HTTP traffic, I want the REGEX to identify lines that ...
3
votes
1answer
38 views

Splitting a large file by column with values in the header as file names

I have a large tab-delimited text file which contains a header and data. I want to split the file into smaller files by column, with the header excluded, and the files named as the column name. pos ...
0
votes
1answer
55 views

Compare strings with specialized charcters

If I have a lookup table cat tmp1 [//rtwttwtr*fgg]\\\erw``~ 1 ^774574574565665f[[[//]\] 2 ()42543^[[D^[[D^[[D^[[D^[[D353535345****@3242- 3 and a number of strings to be looked up from the first ...
2
votes
4answers
362 views

How can I split a line into two lines if the length is greater than 7 using awk? [closed]

For example I just wanted to print something like this in the command line. Let say I have a file called file.txt. What is life? how are you? hi whatup this is more than And I want to print it ...
3
votes
2answers
31 views

Edit file based on existence of a string

I have an input file say file1 which appears as follows WRITE=2 START=1 SMEAR=0 MIN=6 MAX=100 My problem is to search for the string SMEAR and if the string exists replace the entire line with ...
-1
votes
1answer
51 views

Subtract and multiply by constant each two row's values within same column

I have file with two raws like this a1 a2 a3 a4 .... b1 b2 b3 b4 .... I 'd like to get the result of the following subtraction and multiplication process so the third raw will be the ...
0
votes
2answers
34 views

Getting Specific text out of logs

I have log files like this for some top data: Mon May 9 23:45:02 EDT 2016 PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 14816 radius 25 0 848m 415m 10m S 10 2.6 274:...
3
votes
2answers
51 views

Compare multiple files with ref file and print if it matches

I am new dummy user of Unix, so excuse me for maybe easy question. I have multiple files which look like this: b alternate_ids rsid chromosome position alleleA alleleB index ...
24
votes
2answers
1k views

How to merge two text files into one file without using cat or sed [duplicate]

I have two files File1: a b c File2: 1 2 3 now I need to combine them to one csv file a;1 b;2 c;3 As the files are really huge, I would rather not use cat and sed to process the second file. ...
0
votes
1answer
45 views

Matching and storing and the returning information to standard input

So I'm really stuck here. I got some files with millions of lines of data in them formatted like so: username|process name|process time (in minutes) There are close to 3.4 million lines of this ...
1
vote
2answers
25 views

Remove space before second column to maintain pdb formatting

ATOM 9996 CG GLU 622 -13.525 -7.714 -11.215 0.0136 1.9080 0.1094 ATOM 9997 2HG GLU 622 -12.773 -7.608 -11.999 -0.0425 1.4870 0.0157 ATOM 9998 3HG GLU 622 -13.121 -8....
2
votes
2answers
43 views

Replace a string with sequential counter, resetting the counter on each new line

I have a file text (it's an index of names): Variazione su Eraclito, <link-1262>§§§</link> vecchio e il mare, <link-715>§§§</link>, <link-895>§§§</link>, <link-...
3
votes
4answers
92 views

Extract nth line matching pattern and the next N lines

There is a big file containing a pattern which is repeated periodically in the file, I want to extract just a specific pattern after certain values of occurrence as well as the next N lines. Here is ...
1
vote
3answers
37 views

How to add the aggregated numbers in a file

I need to write a script which will add the values for the same string in different lines. For example when a file contains the following: abc,10 xyz,20, abc,30, ghd,40 xyz,10 script should check ...
1
vote
1answer
45 views

Replace one block of text with another block of text when replacement text is in a file

I have two files. The fist file is an existing C/C++ source file (*.cpp). The second is a text file (*.txt) and contains one function. The function is in both files, and it needs to be copied from the ...
0
votes
1answer
25 views

sed - match on IP octet and remove line

I am in need of a solution, preferably sed, that can match on an IP octet that contains any number combination and remove the line. For example: My file: 192.168.100.12 192.168.200.12 10.10.20....
0
votes
4answers
55 views

Replacing spaces (i.e., “ ”) or new lines (i.e., carriage return) with underscores - special case

I want to replace spaces (i.e., " ") or new lines (i.e., carriage return) with underscores in a special case - when they occur between two specific strings. I have html pages and I want to replace ...
0
votes
5answers
85 views

Delete N lines, keep the next N and so on

I want to delete the first 12 lines from a file, keep the next 12 lines and repeat this to the end of the file using a Linux command or shell-script.
6
votes
3answers
255 views

How to remove all comments from a file preserving escaped hash chars

I know that this has been asked before, but this is just a little bit different: I need to remove all comments, excluding escaped # or otherwise not meant as starting a comment (in-between single or ...
4
votes
3answers
380 views

Remove nearly duplicate lines

I've got a knotty problem that I can't figure out how to solve. I have a text file containing a few million lines of text. Basically I want to run uniq, but with a twist: If two lines are identical ...
1
vote
1answer
30 views

Parsing Data File's Lines by Delimiter Instead of EOL

I'm trying to parse a large text file (600MB) of raw data which I have no control on its format. The problem is that the end of line is not placed well: head -1 filename | wc -w Produces a count ...
1
vote
4answers
128 views

How to add a new text line at the first line of a file? [duplicate]

File: TABLE1 1234 9555 87676 2344 Expected output: Description of the following table: TABLE1 1234 9555 87676 2344
1
vote
2answers
37 views

Get the output in a formatted way

In a for loop, I am using the command: echo " Job_time is $i : Stopping the job " Sample output: Job_time is 6 : Stopping the job Job_time is 6.50 : Stopping the job Desired output: Job_time is ...
-4
votes
1answer
40 views

Unpack a shell archive (.shar file)

I have a shell script. How can i remove anything before # this line Everything before the # should be deleted. The script is too long to delete it manually. How can I do that automatically? http:/...
3
votes
1answer
37 views

If there are more than x number of pipes in a csv line, then delete the 2nd instance

I have a csv file which is supposed to contain 4 columns of data which include a product number, a title, a url and a price. Each column is separated by a | delimiter (this has to be maintained, there ...
1
vote
2answers
33 views

Perl script to split a file based on a pattern at a certain offset

I need your help to get an idea as to how to split a large file into small sub-files as said in the example below. Criteria is we are looking at offset 30 (31st bytes to 2 bytes). If the offset ...
2
votes
4answers
285 views

Output negative values, regardless of original sign, on selected lines

I am using the following code to read specific lines in an ASCII file "text.dat" sed -n '/Columnaxis/p' text.dat The output is Columnaxis: 100 In order to output only the second part previous ...
3
votes
1answer
53 views

Print multiple fields based on partial substring match inside one of the fields

From this data: "STRING1","c45621396a774a7a79b095a1b73b1d3b","2016-04-14T19:39:41.529978","1.0.4.4","7-sp1.0-amd64","","10.224.241.219|0.0.0.0|0.0.0.0|192.168.0.6|0.0.0.0" "STRING2","...
-1
votes
1answer
37 views

Unix/Linux - File Formating

We have a source file which needs to be formatted into a fixed width file. Source File Format: Hdr1 Dtl1.1 Dtl1.2 Dtl1.3 Dtl1.4 Trailer0004 Hdr2 Dtl2.1 Dtl2.2 Dtl2.3 Dtl2.4 Dtl2.5 Trailer0005 . . . ...
4
votes
5answers
105 views

How do I sort on the first column every 4 lines in a file with a key in the second column

Example File : first column can have fixed set of 4 unordered values world1.com,world2.com,world3.com or world4.com second column is a key belongs to each line such that each of the four sets has ...
3
votes
1answer
33 views

Replace a word after matched word with incrementing values

I have a file like this - ! interface csa2549abA xxxx yyyy zzzz ! interface aso23apwoeAe aaa bbb ccc ! interface FastEthernet0/1 ppp qqq rrr ! and so ...
1
vote
1answer
26 views

Getting rid of a line with a perfect match (not substring) using sed

I want to delete a line which matches the word name but doesn't delete the lines have something following it. I can't seem to find an answer to this. I know sed -i '/name/d' * would delete the whole ...
3
votes
2answers
124 views

Filter text from each file and turn it into a list of comma-separated values

I'm trying to extract some information from multiple files and create a csv-type file. Until now I got the extracting and writing to file part working but don't know how I could add a comma between ...
3
votes
3answers
109 views

Reverse sequence of a file with POSIX tools?

Is there any clean, clear-cut POSIX equivalent to tac? Readability as well as succinctness should both be considered.
4
votes
4answers
210 views

Delete Nth line from each line matching a pattern

I have several files like file1, file2 ... etc in the same directory and each file may contain several lines matching PATTERN. I would like to delete the Nth line from each line matching PATTERN e.g. ...
4
votes
1answer
393 views

How do I sort words by syllable count?

How do I perform an ascending sort of a word list, based upon how many syllables each word contains? Example Input: something important dog cat bookshelf Example Output: dog cat something ...
0
votes
2answers
46 views

Carriage returns are prevent sed reading all my files

I have a long list of folders, inside every folder I have the file "log.dat". I wanted to read the value of a specific line inside this file. I saved the folders names in a file "All.txt", in the ...
1
vote
3answers
67 views

Delete the nth line from a matched string (which only occurs once in the file)

I have a question related to deletion of strings that appear at the n+2 position after the matched string which is at position n using awk for multiple files. I am able to print it using the command: ...
4
votes
2answers
74 views

Wrap and indent text using coreutils

Short version I would like to create a tabular display of multiline text, similar to the following: all Build all targets document Create documentation of source files in the subfolders ...