1
vote
1answer
60 views

sed “Permission denied” and “No such file or directory” errors while building Clockwordmod

Whenever I execute the command build/tools/device/mkvendor.sh samsung_aegis2vzw /your/path/to/the/boot.img I get this as the output build/tools/device/mkvendor.sh: line 83: /sedcommand: ...
1
vote
3answers
128 views

How can we remove text from start to some particular selected word using sed command in linux

I have a simple query related to selection and replacing text in linux. For explaning question I am using sed command. I have following text. hello world, I am just simple text for display. Now ...
1
vote
3answers
43 views

sed replace text containing new line

I have a bash script for installing a web server on my Ubuntu server. I'd like, in the /etc/apache2/apache2.conf, to replace #ServerRoot "/etc/apache2" # by #ServerRoot "/etc/apache2" ...
2
votes
1answer
38 views

Trying to use GNU Parallel with sed

Why does this line do nothing? I'm trying to run a "sed" command in parallel and it outputs nothing to "standard.txt" $Filetemp = the file I'm stream editing standard.txt = the file I'm outputting ...
0
votes
2answers
45 views

Regular expression

I have a code that is looking for a specific pattern in my log files. Usually it begins with Association ID = (This is what I am looking for in parenthesis). Now the code I have made so far is ...
2
votes
2answers
127 views

How to use sed to substitute current date?

How do I use sed to substitute date by a word. I tried doing this: tmp=`date +%d` echo $tmp if [ $tmp -lt 10 ] then pat="d" echo $pat else pat="dd" echo $pat fi cal | ...
3
votes
2answers
151 views

How to make sed works with break lines from file?

I'm adapting this script to insert file's content into another file. This is what I have now: #!/bin/sh # Check if first and second parameters exist if [ ! -z "$2" ]; then STRING=$(cat $1) # ...
0
votes
1answer
33 views

Count length of letter string

I have a file that look like that (DNA sequence in fasta format): >sequence_name1 ATCGTGATNNNNNNNNAGTCGATCGGATTCT >sequence_name2 NNNNATGTNNATGTCCNNNNNNN I want to count the length of gaps, ...
0
votes
1answer
446 views

Bash script, cannote replace string in a file with escaped $ and &

I have creatd a shell script which takes a string as input. If the string contains '$' or '&', then I need to raplace those characters with '\$' and '\&'. I could done that with sed command. ...
0
votes
1answer
421 views

How to replace strings in file without regex?

I need to replace some strings in files (from command line) but I don't want to use sed -i because my string contains lots of funny characters which need to be correctly escaped. Is there a way to ...
1
vote
1answer
140 views

How to sed two words in a line and add before and after?

I was curious to know if there is a better way to sed two words and add a line before and after them. I learned how from grymoire but I wanted to know if there was a better way to do: #!/bin/sh ...
1
vote
1answer
193 views

How to use sed with this complex expression of special chars and ips?

How to use sed to replace for example this expression: connection = sqllite///keystone@10.10.10.51 with this expression connection = mysql://keystoneUser:keystonePass@10.10.10.51/keystone
1
vote
5answers
1k views

How to remove special 'M-BM-' character with sed

File: https://dl.dropboxusercontent.com/u/32919746/file I have file that was created by copying content from DOCX document with LibreOffice into text file. I have modified file with sed to remove ...
3
votes
2answers
186 views

How to batch organize files?

I have a directory with gigabytes (about 8gb) of small individual files. I want to organize them into directories by date. The date it was created is part of the filename. Here is an example of a ...
0
votes
1answer
270 views

search and replace inconsistency between vim and sed

Using the Ubuntu 12.04 and vim 2.22.0, why inside the vim I shall use: :9s/\d\+/1/ to change first digit of the mentioned line to 1, but couldn't be able to use the same with sed as : sed -i ...
1
vote
1answer
450 views

Tell sed to make changes but those starting with a specific string in 8th to last line

Here again with another problem with sed. As the title says, I want sed to change lines starting at the 8th line to the end, but only lines which start with <b>. I have code all ready and ...
0
votes
2answers
1k views

Inserting variable into sed command in bash script

I have text file similar to this: Some-text Keyword Some-text Some-text Keyword Some-text Keyword Keyword I want to replace every "Keyword" with "number.extension" where number is 1 at first ...
1
vote
1answer
235 views

Configure Fail2Ban with bash script

I'm trying to configure the /etc/fail2ban/jail.local config with an bash script. I was thinking to use sed and regular expression to change the sections I need. sed -i "s/^bantime = 600/bantime = ...
1
vote
2answers
220 views

how to reverse the lower case characters in word using only sed

Reverse every word of a line using sed Description ----------- The job to do is reversing every word of a line. that a word is a sequence of lowercase alphabets Raw Input ...
0
votes
1answer
503 views

sed removes newline at EOF

I've tried using sed to replace an SELECT with BELECT in a file: sed 's/SELECT/BELECT/g' add_pixel.sql | diff - add_pixel.sql Gives me: 22c22 < BELECT MAX(ID) INTO max_id FROM pixels; --- ...
4
votes
3answers
169 views

Search and replace within files

I found the following awesome little script at link $ find /home/bruno/old-friends -type f -exec sed -i 's/ugly/beautiful/g' {} \; But I really do not understand the final bit {} \; ...
3
votes
3answers
3k views

How to find text and replace that line if exists with terminal otherwise just append line to end

I want to put in sudo gedit /etc/sysctl.conf the one line vm.swappiness=10 which I sometimes change. By default this line doesnt exist so I use echo "vm.swappiness=10" | sudo tee -a /etc/sysctl.conf. ...
18
votes
1answer
78k views

how to use variables in SED?

I try the fallowing code and it does nothing var1=QQ sed -i 's/$var1/ZZ/g' $file However this code replaces QQ with ZZ sed -i 's/QQ/ZZ/g' $file how to use variables in SED?
6
votes
2answers
10k views

How to escape file path in SED?

I would like to replace $fileWithPath in $file, however this not works because (I think) path is not escaped. how to escape it? sed -i 's/${fileWithPath}/HAHA/g' $file
0
votes
2answers
618 views

Problem using `sed` to colorize `ls` output (Tenth back-reference `\10` not working)

I had asked this question a while back: Is it possible to colorize permissions-part of the output of ls? While the accepted answer in that question is OK, I now want to do the same thing without ...
1
vote
2answers
641 views

how to use grep in a conditional search previous to a sed text replace command

I am trying to change the path in whole lot of m3u files. I know I can do it with regexxer f.e. but I'm trying to learn bash. This is the command I figured out, but it is not working. grep -lr -i -e ...
2
votes
2answers
1k views

Sed problem in a Bash script

I'm having a problem using the sed command . I'm trying to write a bash script that does the following : search for the line that contain :@ then save the line that contained :@ and replace it ...
2
votes
1answer
5k views

How can I remove the first line of a file with sed?

the following lines append the content of essay_i.txt to the end of essay1.txt; touch essay1.txt for (( i = 1 ; i <= 10 ; i++ )); do sed '2p' essay_"${i}".txt >> essay1.txt done how should ...