"sed" ("stream editor") is a Unix utility that parses and transforms text files.

learn more… | top users | synonyms

4
votes
2answers
14k views

How do I encrypt Samsung 840 SSD with Bitlocker?

I need help encrypting my Samsung 840 Evo with Bitlocker. Here is my hardware: Samsung Evo 840 500GB hard drive (firmware EXT0BB6Q) Asus P8z77-v motherboard (BIOS v. 2104) Asus TPM chip - purchased ...
20
votes
4answers
15k views

Newlines in sed on Mac OS X

I find that \n doesn't work in sed under Mac OS X. Specifically, say I want to break the words separated by a single space into lines: # input foo bar I use, echo "foo bar" | sed 's/ /\n/' But ...
3
votes
4answers
1k views

Mass Rename Files with bash

I've got a bunch of numbered files like this: file #01.ext file #02.ext file #03.ext file #04.ext file #05.ext And what I want is to make them all have three digits (two leading 0's) instead of one,...
2
votes
3answers
4k views

How can cat/print a file except the last 2 lines?

How can get a file, except the last (for instance) 2 lines, with standard or GNU shell tools? (bash, tail, cat and so on.)
1
vote
1answer
121 views

Using cURL command-line tool on Mac, What can I do to this script to ask it to fetch stock data which will replace commas with NO SPACES

Example: Google Outstanding Shares are 670,000,000 and this value is collected in a txt file from Yahoo Finance API via the below script. The issue is; that numbers WITH commas or spaces are a bloody ...
17
votes
6answers
11k views

Removing ANSI color codes from text stream

Examining the output from perl -e 'use Term::ANSIColor; print color "white"; print "ABC\n"; print color "reset";' in a text editor (e.g., vi) shows the following: ^[[37mABC ^[[0m How would one ...
3
votes
2answers
2k views

Sed replace between 2 strings with special character

I have an XML file containing a code and to use it with xmllink I need to remove a link. XML file containing: <xml version="1.0" encoding="UTF-8" standalone="yes"?> <PackingList xmlns="Link ...
0
votes
1answer
213 views

Sed replace line stored in a variable

I need to find a line that starts with mysql.unmetric.twt.url and replace the entire line with line stored in the variable ip. ip="mysql.unmetric.twt.url=jdbc:mysql://ec2-a-b-c-d.compute-1.amazonaws....
9
votes
1answer
4k views

Can GNU sed (for Windows) handle Unicode? If so, is it a code-page/locale issue, or a switch?

I've been using GNU SED on and off for a couple of years now. It spins me out a bit sometimes, but it does a good job... for single-byte char sets! I now and then notice references to GNU SED being ...
3
votes
2answers
10k views

Replace special text with sed?

I'm using CMD on Windows Xp to replace special text with Sed. I'm using this command for replace special characters like $ or * : sed -i "s/\*/123/g;" 1.txt But how command must i use to replace ...
3
votes
4answers
2k views

How to replace a list of strings by another list

I have a file which has (many) strings I'd like to replace, so I thought about using a simple command like: sed 's/string1/string2/g' file1 > out However, there are too many strings for that ...
2
votes
2answers
9k views

Sed only print matched expression

How to make sed only print the matched expression? I want to rewrite strings like "Battery 0: Charging, 44%, charging" to "Battery: 44%". I tried the following: sed -n '/\([0-9]*%\)/c Battery: \1' ...
2
votes
2answers
341 views

Sed command with apostrophe

sed -e 's/cluster_name: 'Test Cluster'/cluster_name: 'Test Cluster1'/' I have this error message: sed: -e expression, char 20: unterminated `s' command Please, how can i correct the sed command ...
2
votes
1answer
355 views

sed: Removing \r\r before \n in a very large file

I have a corrupted disk image file (about 27 GB) in which before all \n characters \r\r was inserted. I want to remove these \r\r before all \n. I tried with awk: awk '{ sub("\r\r$", ""); print }' ...
1
vote
1answer
2k views

Using a table or script in sed to replace many special characters with escape characters?

If u want replace special characters using sed you can use different ways, but the problem is you have to replace many (100+) special characters with escape characters in many files. so it needs: (...
1
vote
1answer
773 views

Batch renaming of files in a directory using sed

I run a script which generated about 10k files in a directory. I just discovered that there is a bug in the script which causes some filenames to have a carriage return (presumably a '\n' character). ...
0
votes
2answers
514 views

Find Files With Similar Name to Folder

I'm on OS X, and I have a folder that contains a number of subfolders. There are two things I want to do. The first is to ensure that each subfolder has a file in it of the form [subfolder-name].grade....