Manipulation of text by programs, scripts, etc.

learn more… | top users | synonyms

1
vote
1answer
23 views

How to append the first line at the end of each line of a file with Sed?

I'm trying to append the first line of a file at the end of each line with a single sed command: Example: line 1 line 2 line 3 line 4 should become: line 1 line 1 line 2 line 1 line 3 line 1 line ...
1
vote
2answers
35 views

unix - select specific lanes from logs

I need help with selecting specific data's from log files. I need two scripts: I need to select all IP addresses that only visited /page1 I need to select all IP addresses that visited /page1 but ...
3
votes
2answers
32 views

Get a string and place it at the start of a line until the next string is found

I have a big non-standard xhtml file that i'm using sed (about 4 times) to iterate down to just the basics I need to throw the data into a MySQL database. My last bit i'm struggling with. The file is ...
3
votes
2answers
69 views

Organizing three dimensional data with awk/sed/perl

I have this file (a sparse matrix): PC.354 OTU1 6 PC.354 OTU2 1 PC.356 OTU0 4 PC.356 OTU2 7 PC.356 OTU3 3 I want an output like this (dense matrix -classic .biom table): OTU_ID PC.354 PC.355 ...
1
vote
1answer
18 views

Library database

I have a database of readers and I would like to lend them a book and write it into the database. Example: Reader 753 Leonardo DaVinci davinci@gmail.com 321654987 Lended Books: grep ...
0
votes
2answers
25 views

Generating wordlist permutations from existing files

I have two wordlist files; the first contains: John Jerry Jim the second contains: one two three The files are several thousand lines each, not just the 3 words above. How can I generate ...
0
votes
2answers
22 views

Adding 'exception' words to the rule of perl matching titles script

I have been using this perl script (thanks to Jeff Schaller) to match 3 or more words in the title fields of two separate csv files as answered here: Matching 3 or more words from fields in separate ...
0
votes
3answers
58 views

How can I retrieve and compare two values from a file? [on hold]

How can I retrieve and compare two values from the first two lines of a file? I have the following text: 05-24-2016, 2:59:32,0,0 05-24-2016, 2:59:37,0,0 05-24-2016, 2:59:42,0,0 05-24-2016, ...
0
votes
3answers
48 views

How to extract logs between the current time and the last 15 minutes

I want to extract the logs between the current time stamp and 15 minutes before and sent an email to the people configured. I developed the below script but it's not working properly; can someone help ...
2
votes
1answer
36 views

How to standardize the number of characters in a column?

I have a column (in my data-file database) where the number of characters is not standardized, and need to standardize. How can I do it? Example: Sample_ID 159 148 1110 1100 150 But my bank does ...
3
votes
4answers
56 views

Remove a certain word in a file

How do I remove just abcd11.gmail.com and *test1: from line 1 and abcd14.gmail.com and *fortest2: from line 2 and abcd19.gmail.com and *asatesteg: from line 2 from below leaving the remaining as is? I ...
0
votes
1answer
47 views

Using regexp_replace to replace single quotes around string but not within words e.g. can't

I'm using the below code from a bash script to replace single quotes from my title column in a postgres database with spaces. psql -U postgres -d my_database -c "UPDATE my_table SET title = ...
1
vote
1answer
34 views

Sort text by specific location on each line

What I want to achieve is sorting lines of text by a specific point in the text (the lines of text have no spaces or columns). I've worked out a solution to this, but I want to know if there is a more ...
3
votes
1answer
42 views

Substitute text fields with values from other file

Alright, I cannot figure out how to do this. I have a fileA which looks like this : ([7]RIMS_ID) : "CNR" (refGain_A[7]) ...
0
votes
0answers
24 views

copying every 2nd line starting from 1 [duplicate]

The below has actually been asked before, which I hadn’t realised. but out of curiosity, how would you go about it if you wanted not just odds or evens, for example every 5th line I'm trying to copy ...
1
vote
2answers
64 views

Removing spaces from the fields in a semicolon-delimited file using shell script

I have a csv file like this: 03139; 5; IT1234978208; 20150930 ; CTZ 13/31.12.15; 03137; 6; IT1234978206; 20151015 ; CTZ 13/31.11.18; .... .... 03134; 8; IT1234974406; ...
-1
votes
0answers
18 views

Word processing [on hold]

When I backspace in a word doc to erase to the left, the cursor always jumps to the right end of the line and erases. Are all word processors like this and how do I avoid it? This is a real nuisance.
-3
votes
0answers
19 views

Evaluating a Question Generation System [on hold]

I'm finishing a System that generates questions automatically from declarative sentences. Example: "The capital of Russia is Moscow" The system may generate questions like: What is the capital of ...
1
vote
2answers
46 views

find string from one file in another if not present then remove from original file

I'm trying to make a script that looks through each line of one file and if a line fails to match anywhere in any line of another text file then remove that line from the original file. so far I've ...
1
vote
1answer
44 views

How to find match with surrounding words?

I want to find match with surrounding words. I also want it to be fast. Here's what I've got: grep -o -P '(\w+ ){0,n}match( \w+){0,m}' n is number of words before the phrase, m is number of words ...
2
votes
4answers
53 views

Create text corresponding to multiple variable assignments from a single variable

I have a variable that has a value like this line=dog,/path1,/path2 What I want is to create a variable from the value; i.e dog should be the variable and want to get the below output: ...
3
votes
1answer
41 views

Modify values in a column based on number of colons it contains

I would manipulate the contents of the second column based on the number of colons it contains. If the second field contains more than one colon then I would require the content before first colon ...
3
votes
5answers
308 views

Increment index in file

Alright, it seems I cannot find a way to do what I need. Let's say I have a text file A like this (freqBiasL2[27]) (SatBiasL1[27]) (defSatBiasL2_L1[27]) (defSatBiasSlope[27]) ...
-3
votes
0answers
30 views

How to compare an input name (first and last) with names in a file (revised) [closed]

How do you compare an input name (first and last) with names in a file and print out either name is good or name is bad? I can't seem to find this anywhere. Do I need to set up the file a certain way? ...
3
votes
1answer
27 views

Use a list file to extract a second list from a master file (and comment out some lines)…HOW?

I have two files: master.tbl and sites.lst The file master.tbl is a list of sites, with their port configurations, port names, IP addresses, etc. There are lines containing site descriptions, ...
0
votes
1answer
25 views

Each line into a file (XML as part of file)

Here is a sample of the content in the file: <:abc>test file name <:/abc> XYZ 1122 XML content is pretty heavy and big. Under the directory I am working in I want to create a ...
0
votes
4answers
53 views

Duplicate the content of a file

I have a requirement where if a specific condition is met I need to duplicate the whole content of a file into the same file. Here is the file: $ cat in.txt ip 10.22.1.34 10.22.1.35 When a ...
0
votes
1answer
39 views

Remove lines from a file

In my output file I have the below lines included multiple times along with the required output. WARN: The method class org.apache.commons.logging.impl.SLF4JLogFactory#release() was invoked. WARN: ...
-1
votes
3answers
26 views

Count non-zero numbers for each row of a second column in a text file

I have a text file in that each line words are separated by commas, like this: 7022122465,0,\N,,0,2015-09-29 10:48:33 7022597642,0,\N,,0,2015-09-29 10:48:33 7022848906,0,\N,,0,2015-09-29 10:48:33 ...
0
votes
1answer
49 views

sed use from android shell

I am getting familiar with sed on the android terminal emulation: the version I am using the sed included in the toybox which is installed on my unrooted Sony device. sed --version (or toybox sed ...
1
vote
2answers
41 views

sed + add last word on each string only if word not appears

I have the following file: linuxA.mtt.corp linux3V linux4B linux2A linux5v.mtt.corp how to add the .mtt.corp on each string that not have this word?
1
vote
1answer
46 views

Matching 3 or more words from fields in separate csv files

I have two csv files: This is csv1: 11, The Sun Still Shines in Reading, 64312, 464566 13, You and Me Together Again London, 564564, 131355 12, What's the Story Now Your Gone, 4545646, 1124545 17, ...
4
votes
2answers
174 views

Display file text one page at a time, wait 20 seconds, then auto-advance

This question is for AIX 7 I have been working on a monitor which will display several pages of text. Initially the end user wanted a scrolling list for which I constructed this: IFS=''; cat plfeed ...
1
vote
1answer
32 views

find matching URLs in a line, then shorten them to the domain name

I am new to the Linux command line and need some help. I have a log file I am writing a script for so it only shows certain fields of output. The last bit I need is to shorten the URL's so that it ...
-3
votes
2answers
37 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
74 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 ...
6
votes
1answer
37 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
417 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 ...
1
vote
3answers
46 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
39 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
28 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
44 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
81 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
30 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
36 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
52 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
338 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 ...