sed is a command-line stream editor for filtering and transforming text.

learn more… | top users | synonyms

0
votes
3answers
59 views

i want to extract the value from html tag using sed

i want to extract the value from html tag using sed file: <td class=xl7128074></td> <td class=xl7128074></td> <td class=xl7128074></td> </tr> <tr ...
2
votes
1answer
50 views

How to choose the highest number element in many files with many arrays

I have many files which each one contain many arrays(like input 1 and 2, below). Each array has two element numbers in the second row. I need to use a logical criterion to choose the highest number ...
0
votes
2answers
40 views

Sum column numbers elements in many arrays

I need to sum the the numbers located in the same column in an array. The input is: 1: 6.1703 44 3.5 0.3 46 7.3 2.3 2: 6.1932 44 5.29379 2.9 46 1.72261 7.2261 3: 6.5664 45 4.756 5.6 46 1.6 2.5 4:...
0
votes
0answers
33 views

awk or sed Commands to Print Columns at desired locations [duplicate]

I have a source file which contain 15 columns and so may rows: 2973695.500 633952.188 2440.000 255 0 255 1 1 OP UNK opt TIME SKZ meter ms 2973695.500 633952.188 2440.000 0 255 255 1 1 ...
-1
votes
1answer
39 views

Extract string from first character till string pattern

I have a implicit file with **$&*#@** as field delimiter and **$#@&*** as record delimiter. Below is an example, 100$&*#@200$&*#@50$&*#@Some String$&*#@2016-01-01 101010$#@&...
0
votes
0answers
31 views

get user input in terms of size (GB or MB)

I created script to calculate shmmax shmall shmmini Total_Memory_M=$(dmidecode -t 17 | grep Size | awk '{print $2}' | grep -o '[0-9]\+' | paste -sd+ | bc) Total_Memory_G=$(echo $Total_Memory_M /1024 |...
1
vote
1answer
40 views

Replace only the first character of a matched pattern

I need to write a sed command that reads from a file and replaces the first character in each line with 0, only in the event that the first and second character in that line is a digit (and leave the ...
0
votes
3answers
61 views

Regex pattern to replace multiple values via sed

I have a script in which I need to parse the IP address of the localhost, and replace the 2nd octet with a different value, but the value being substituted depends on what the value currently is... ...
3
votes
3answers
52 views

Grep/awk/sed for lines composed of only two letters, and lines that start with a letter and meet a certain length

Not sure how many people are familiar with DNA sequencing data, but if this is part of my file (lines starting with ">" are IDs, and lines starting with a letter are DNA sequences): >NB501013:9:...
0
votes
1answer
24 views

Performing Prime Key function using 'Sed' in Bash

I am using bash and trying to employ sed command for matching a string and replace it with another between two files. Objective: To replace all strings[sp_*] by matching them from another file ...
2
votes
2answers
45 views

Print text between two strings - omit second occurrence

I have an instruction file with a lot of steps. I'd want to view a single desired step in a shell, without graphical environment. What I do right now, as pointed out by alemol, is using sed to extract ...
1
vote
1answer
38 views

Array indexing using “sed”

I am working on one shell script which search directory modified in last 24 hours and then compress them using tar. Folder Search : find /path to log directory/ -maxdepth 1 -type d -mtime +0 ...
1
vote
2answers
41 views

How to append some string combined with the pattern at the end of line with the pattern

I want to append .com at the end of line for every line matching the pattern in /etc/hosts file. Sample file content: 127.0.0.1 localhost 1.2.3.4 hostname1 hostname1.xyz hostname1.xyz. 1.2.3....
0
votes
1answer
26 views

How to move lines between patterns to the end of a file

I want to move several lines to the end of the file. Example: 1 2 3 4 5 6 blkn XYZ indf 7 8 9 10 11 lnkn ABCYDF knnfd 12 13 14 15 I want to move lines 6 to 11 to the end of the file. The patterns ...
3
votes
6answers
793 views

How do I remove a words ending in the letter S if duplicates without an S on the end are on the same list?

I have a large list of words. Many of the words are only different because they have the letter s on the end. If a word on the list is the exact same as another word on the list, except one of the ...
1
vote
3answers
39 views

How to delete whitespace surrounding equal signs in a string?

I'm trying to determine a way to delete leading and trailing whitespace surrounding the equal sign from a string. The whitespace may (or may not) be present. There may be 0, 1 or more equal signs. I'...
2
votes
1answer
30 views

sed whole string replacement not working

I have two scripts ins.sh and variable.sh. variables.sh holds various key-value pairs. ins.sh #!/usr/bin/env bash set -e # Exit upon error # This script generates a 64-bit system source variables....
2
votes
1answer
34 views

How can I use sed to snip a line off of a string?

I'm writing a script to display the domain registrar info and I'm trying to snip off a few lines from what I already have I currently have it grabbing all the indented text from a whois. Now I'm ...
2
votes
1answer
25 views

Source of “gsed: can't read : No such file or directory”?

I have a Bash script that performs a simple substitution on OS X. Here's the reduced case: mkdir vs2005-dynamic cp cryptdll.vcproj cryptest.sln cryptest.vcproj cryptlib.vcproj dlltest.vcproj vs2005-...
3
votes
1answer
56 views

Join arbitrary lines to output as one line

I want to join the 3rd and 5th line of a file to the output of a script without trailing new lines. Is it possible to implement this construction by using the code: { echo 'Some text' echo 'Some ...
1
vote
1answer
26 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 ...
0
votes
1answer
32 views

Understanding sed expression

I am a beginner and would appreciate help on the interpretation of the sed+awk command below, sed -e '1,$s/ /:/g' -e '1,$s/;/:/g' |awk -F ":" '{print $1,$2,$3,$4,$12,$14,$18,$20,$22,$24,$26,$28,$30,$...
-1
votes
1answer
34 views

sed and special characters [closed]

I'm trying to use sed to replace </link> or </title> by a space in a file, I'm using. sed -i 's,</link>,,' file.txt if I use the same command but without the / it works, but with ...
11
votes
3answers
755 views

How do you remove dot character from string without calling sed or awk again?

I have a file called hostlist.txt that contains text like this: host1.mydomain.com host2.mydomain.com anotherhost www.mydomain.com login.mydomain.com somehost host3.mydomain.com I have the ...
3
votes
2answers
45 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
86 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 PC....
1
vote
3answers
58 views

Awk/sed: add line numbers to text from within a range

So I have a range, say 2-4. And I have three lines: first second third I need my output to be: 2 first 3 second 4 third I'm trying this on BSD (Mac) awk/sed, which seems to be making it harder.
1
vote
1answer
56 views

Adding/removing some tabs and line breaks in an HTML code using sed

I want to refine an HTML code using sed, as an extra refinement procedure after refining it using HTML Tidy, as HTML Tidy doesn’t look flexible enough for some requirements. I used this command to ...
1
vote
1answer
19 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 "...
1
vote
2answers
30 views

replace the content of one field based on the content in another field

I would like to divide the first column based on the delimiter, here -. Based on the last value, last column, here column 2, should be populated. If the value is 01 or 99 then replace with 2 or 1 ...
0
votes
3answers
48 views

Extracting a date from a log file and creating a file with unique dates

I would like to extract from a file the date with format DD.MM.YYYY, date is always in the first place, here an example of the entries 15.04.2016 13:13:30,228 INFO [wComService] [mukumukuko@system/...
2
votes
3answers
36 views

How to edit next line after pattern using sed?

Using sed, how do I search for a line ending with foo and then edit the next line if it starts with #bar? Or put another way, I want to remove a comment # from the next line if it starts with #bar ...
0
votes
3answers
62 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 ...
1
vote
1answer
32 views

Need help with sed/awk with deleting string

i have a txt file contenting the following information -Xmx4096m -Xms4096m -verbose:gc -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+ScavengeBeforeFullGC -Dsun.net.inetaddr.ttl=3600 -XX:...
1
vote
2answers
73 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; ...
0
votes
1answer
35 views

have a log file that I would like to break up into several files based on content

I have a log file that I would like to break up into several files Table of Contents *** Configuration Database *** Logs *** Configuration Logs *** Query Logs . . and so on The issue ...
-1
votes
2answers
84 views

Have sed echo string after match

I need to have the string directly following/pbs.twimg.com\/profile_images\/echoed out. This is for a search tool I have created with a bit of help, and everyone recommends sed, but I never really use ...
3
votes
3answers
103 views

Replace a long string with the sed command: Argument list too long error

I'm trying to execute this command sed -i -e "s/BASE_64/$BASE_64/" FILE_NAME where $BASE_64 is a base 64 representation of a file content. sed gives me an error since the string is too long. ...
-4
votes
1answer
33 views

Can anyone explain in detail the following two commands regular expressions

The following two commands used to count no of non-zero integers of second column in the text file. Can anyone please explain the regular expression in detail. grep -c '^[^,]*,[^0][^,]*,' < myfile....
0
votes
0answers
37 views

sed can't find file on a shell script [duplicate]

I've been running into a problem whenever I run the shell script containing a sed. If I try this argument by running the shell script with the following line, it gives me a bizarre error: arg=$1; ...
-1
votes
3answers
30 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 ...
-1
votes
3answers
44 views

Insert array of years into a list of URLS

I have a list of URLS like the example below. /test/test I also have an array of years [1999, 2000, 2001]. I am trying to find a way to automate the task of printing out a list of URLS with ...
0
votes
1answer
63 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
44 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?
3
votes
2answers
159 views

sed command with option -n and '$='

I want to print number of lines in a file using the sed command. I have the following line for that, please can any one explain in detail. sed -n '$=' myfile.txt
1
vote
2answers
39 views

awk + how to append list in file

I have the following list in file more file.ex efifc1a hygg4a hdy5d nhdw4s wesf3a fjfhyr jfhg gsfar how to append any second list after the first list and any third list after the second list ...
0
votes
0answers
27 views

RE error: repetition-operator operand invalid

I'm getting this error RE error: repetition-operator operand invalid On FreeBSD sed, using csh. Command is: sed -rn 's/.*?VIEW ([^\s]+?) (AS .*?)\s([^\s]+?)\s([^\s]+?)/DROP VIEW \1;\nCREATE ...
0
votes
0answers
34 views

sed using a bash variable [duplicate]

I am attempting to identify 2 lines a in a file, that match a pattern (path) $ dir_target="./CUSTOM/Database/XXRBS/DML/Insert" $ cat csv.out ./CUSTOM/Database/APPS/DCL/Grant/xla_distribution_links....
0
votes
2answers
40 views

Renaming multiple files using sed

I have following set of files top_axi_256_wrapper_05.02.01.14.00_sample06.tgz top_axi_128_wrapper_05.02.01.14.00_sample06.tgz I want to replace 05.02.01.14.00 part with 05_02_01_14_00. So the ...
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 : ...