sed - go to file and search a part and set at the end text


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed - go to file and search a part and set at the end text
# 8  
Old 09-09-2016
I guess you have a newline in your variable? Like in
Code:
BIG_PORTS="111,222,333,444,555,666,777,888,999
"

# 9  
Old 09-09-2016
No, issue while paste
Thats my/your Code:
Code:
BIG_PORTS="111,222,333,444,555,666,777,888,999"
sed -i "/\<$BIG_PORTS\>/ "\!"s/^OPEN_TCP=\"/&$BIG_PORTS,/" /etc/arno-iptables-firewall/firewall.conf

ggf. kann ich es in Deutsch besser erklären?

---------- Post updated at 04:46 AM ---------- Previous update was at 04:25 AM ----------

if i try this:
Code:
BIG_PORTS='111,222,333,444,555,666,777,888,999'
sed -i "/\<$BIG_PORTS\>/ "\!"s/^OPEN_TCP=\"/&$BIG_PORTS,/" /etc/arno-iptables-firewall/firewall.conf
sed -i "1170s/\n/ /" /etc/arno-iptables-firewall/firewall.conf

i get this output in terminal:
Code:
root@mail:~# bash ~/sed-test.sh
: No such file or directoryptables-firewall/firewall.conf
root@mail:~#

i do not understand.

I use notepad++ and "UTF-8 without BOM"
# 10  
Old 09-09-2016
That last error message indicates a <CR> char in the file name. Use a decent *nix editor or switch editor mode to UNIX (if available).
If that doesn't help, post the result of
Code:
od -ctx1 file

of (a representative part of) your input.
# 11  
Old 09-09-2016
I found the issue

The notepad++ has an option "open New Dokuments in utf" and then a checkbox "also ANSI"

So i open the file over winscp into notepad++ and He convert it into utf



Gesendet von meinem C6903 mit Tapatalk
# 12  
Old 09-09-2016
So - which solution do you deploy right now? Please post/share it!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read in search strings from text file, search for string in second text file and output to CSV

Hi guys, I have a text file named file1.txt that is formatted like this: 001 , ID , 20000 002 , Name , Brandon 003 , Phone_Number , 616-234-1999 004 , SSNumber , 234-23-234 005 , Model , Toyota 007 , Engine ,V8 008 , GPS , OFF and I have file2.txt formatted like this: ... (2 Replies)
Discussion started by: An0mander
2 Replies

2. Shell Programming and Scripting

How to add a line to the end of a set of files without using sed command?

I understand that the SED command reads all the lines in the file before adding a required line to the end of the file. Is there another command that adds a line to the end of files without reading the entire file.... SED is increasing the processing time as the number of lines in each of the... (1 Reply)
Discussion started by: Kanch
1 Replies

3. Shell Programming and Scripting

Search from a line to end of list using sed

Dear Unix Experts :), Below is a small section of a large file with the following list: 1. Starts with string " interest" as the heading 2. Followed by a list of activities 3. Ends with a blank line before starting with another different list. E.g. Sporting interest football... (13 Replies)
Discussion started by: gjackson123
13 Replies

4. Shell Programming and Scripting

Search a string in a text file and add another string at the end of line

Dear All I am having a text file which is having more than 200 lines. EX: 001010122 12000 BIB 12000 11200 1200003 001010122 2000 AND 12000 11200 1200003 001010122 12000 KVB 12000 11200 1200003 In the above file i want to search for string KVB... (5 Replies)
Discussion started by: suryanarayana
5 Replies

5. Shell Programming and Scripting

deleting the part of the file(overwrite) using start and end point

here is the contents of bigfile.sql CREATE TABLE `Table11` ( `id` int(11) NOT NULL , `entityName` enum('Lines','EndUsers') COLLATE utf8_unicode_ci NOT NULL, `parentAllianceMigrationProjectId` varchar(255) NOT NULL ) ENGINE=InnoDB AUTO_INCREMENT=2000 DEFAULT CHARSET=utf8... (30 Replies)
Discussion started by: vivek d r
30 Replies

6. Shell Programming and Scripting

Using sed to put text end of line

how to use sed to put .txt end of line..my input file below file1 make=^bak12^". DEV=LONG^cmd/usr/bak/ade4^" ..................................... file 2 make=^and_LONG/bak12^". DEV=LONG^cmd/usr/bak/ban3^" .......................................... file 3... (6 Replies)
Discussion started by: zulabc
6 Replies

7. Shell Programming and Scripting

search needed part in text file (awk?)

Hello! I have text file: From aaa@bbb Fri Jun 1 10:04:29 2010 --____OSPHWOJQGRPHNTTXKYGR____ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline My code '234565'. ... (2 Replies)
Discussion started by: candyme
2 Replies

8. Shell Programming and Scripting

Append text from one file to another based on a search from the end of a document

Hi all, I have output files that are all text files with various different extensions. So, if I submit the input file "job_name.inp", when it finishes I get an output file "job_name.dat". A typical input file looks something like this: $CONTRL SCFTYP=RHF RUNTYP=ENERGY MAXIT=199 MULT=1... (4 Replies)
Discussion started by: marcozd
4 Replies

9. UNIX for Dummies Questions & Answers

using sed to append text to the end of each line

Anyone know how to use SED to append a comma to the end of each line example: field1,field2,field3,field4 If i Cat /textfile ---- How can i append the end of /textfile with a comman? (8 Replies)
Discussion started by: Redg
8 Replies

10. Shell Programming and Scripting

How do you search and replace a text with markerA that end with markerB

Hi all, How do you replace all lines that begin with markerA and end with markerB? Ex: I have a file with a list of lines. /sbin/fsck -> $(SEC_CRIT) ; /sbin/fsck.ext2 -> $(SEC_CRIT) ; How can I replace all "->$....;" with a blank space... (1 Reply)
Discussion started by: drone
1 Replies
Login or Register to Ask a Question