Sponsored Content
Top Forums Shell Programming and Scripting Edit file content at the specific line. Post 302505944 by ctsgnb on Friday 18th of March 2011 04:43:24 AM
Old 03-18-2011
Add "anyword" at the end of line 2 :

Code:
# cat tst
a1111,222 2222,333333,22222 22,555555 555
b1111,2222222,333333,444444 4444444,55555
a1111,222 2222,333333,22222 22,555555 555
a1111,222 2222,333333,22222 22,555555 555
a1111,222 2222,333333,22222 22,555555 555
#

then
Code:
# printf "2s/.*/& anyword/\nw\nq\n" | ed -s tst

or
Code:
# printf "2s/$/ anyword/\nw\nq\n" | ed -s tst

will give

Code:
# cat tst
a1111,222 2222,333333,22222 22,555555 555
b1111,2222222,333333,444444 4444444,55555 anyword
a1111,222 2222,333333,22222 22,555555 555
a1111,222 2222,333333,22222 22,555555 555
a1111,222 2222,333333,22222 22,555555 555
#


Last edited by ctsgnb; 03-18-2011 at 05:49 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script to edit the content of a file

Hi I need some help using shell script to edit a file. My original file has the following format: /txt/email/myemail.txt /txt/email/myemail2.txt /pdf/email/myemail.pdf /pdf/email/myemail2.pdf /doc/email/myemail.doc /doc/email/myemail2.doc I need to read each line. If the path is... (3 Replies)
Discussion started by: tiger99
3 Replies

2. AIX

find for specific content in file in the directory and list only file names

Hi, I am trying to find the content of file using grep and find command and list only the file names but i am getting entire file list of files in the directory find . -exec grep "test" {} \; -ls Can anyone of you correct this (2 Replies)
Discussion started by: madhu_Jagarapu
2 Replies

3. Shell Programming and Scripting

Script to Edit the file content and create new file

I have a requirement, which is as follows *. Folder contains list of xmls. Script has to create new xml files by copying the existing one and renaming it by appending "_pre.xml" at the end. *. Each file has multiple <Name>fileName</Name> entry. The script has to find the first occurance of... (1 Reply)
Discussion started by: sudesh.ach
1 Replies

4. Shell Programming and Scripting

Remove specific content in a file

Hi, I have a file called fl_list consists of files i have to archive. I want to create a exception parm called except_parm, so if it finds the directory it will not archive these files and remove from fl_list. $ cat fl_list /apps/dev/ihub/ready/IA003B/IA003B_Deal_Header_yyyymmdd_hhmmss.txt... (1 Reply)
Discussion started by: k9cheung
1 Replies

5. Shell Programming and Scripting

Extract specific content from a file

My input file: >sequence_1 ASSSSSSSSSSSDDDDDDDDDDDCCCCCCC ASDSFDFFDFDFFWERERERERFSDFESFSFD >sequence_2 ASDFDFDFFDDFFDFDSFDSFDFSDFSDFDSFASDSADSADASD ASDFFDFDFASFASFASFAFSFFSDASFASFASFAFS >sequence_3 VEDFGSDGSDGSDGSDGSDGSDGSDG dDFSDFSDFSDFSDFSDFSDFSDFSDF SDGFDGSFDGSGSDGSDGSDGSDGSDG My... (22 Replies)
Discussion started by: patrick87
22 Replies

6. Shell Programming and Scripting

Script to Check & Edit Content of a file (Addition of comma in each lines of code)

Hi all, I need to write an automated bash shell script which performs such operations: 1. Grep the header of everyline with the initial of "T" in "FILE_A" 2. Perform a for loop, Count the numbers of comma in the line of code, if (no. of comma < 17) ADD the comma until 17; ... (2 Replies)
Discussion started by: big_nutz
2 Replies

7. Shell Programming and Scripting

How to edit specific variable in file?

HI guys i have a question. Question 1: how do i modify a particular string? e.g echo "Please enter Book Title: " read a echo "Please enter Author: " read b if ] then echo " Record found!" which will then pop out a menu with the follow output 1. Update Name 2.... (1 Reply)
Discussion started by: ichar
1 Replies

8. Shell Programming and Scripting

want to print the file content from the specific line

Hi All, I would like to print the content from the specific line of a file . For example... i have file abc.txt which has 100 lines of code ,from this file i would like to print the content from 20,19,18th line......like that Regards Srikanth (4 Replies)
Discussion started by: srikanthg
4 Replies

9. UNIX for Dummies Questions & Answers

Deny to edit a specific file in sudoers

How do I deny a user to edit a specific file in directory but the user will have a capability to use sudo and execute any command? I will just deny him/her to edit sayy 5files in different directories in linux? example. He cannot edit /etc/modprobe.d/blacklist.conf and /etc/sshd.config? Then the... (6 Replies)
Discussion started by: lhareigh890
6 Replies

10. Shell Programming and Scripting

Extract specific line in an html file starting and ending with specific pattern to a text file

Hi This is my first post and I'm just a beginner. So please be nice to me. I have a couple of html files where a pattern beginning with "http://www.site.com" and ending with "/resource.dat" is present on every 241st line. How do I extract this to a new text file? I have tried sed -n 241,241p... (13 Replies)
Discussion started by: dejavo
13 Replies
RDS-GEN-SINK(1) 					    BSD General Commands Manual 					   RDS-GEN-SINK(1)

NAME
rds-gen -- write data from a file to an RDS socket rds-sink -- write data from an RDS socket to a file SYNOPSIS
rds-gen [-s source_address:source_port] [-d destination_address:destination_port] [-f input_file] [-m message_size] [-l total_bytes] [-i interval] rds-sink [-s listen_address:listen_port] [-f output_file] [-i interval] DESCRIPTION
The rds-gen and rds-sink utilities are used to stream data through RDS sockets. rds-gen reads data from a file descriptor and sends it as messages down an RDS socket. rds-sink receives messages from an RDS socket and writes it to a file descriptor. The following options are shared between rds-gen and rds-sink: -s address:port Binds the RDS socket to the given address and port. rds-gen will send messages from this address and port. rds-sink will receive messages sent to this address and port. -f file rds-gen will read data from this file and rds-sink will write data to this file. If '-' is given as the filename then rds-gen will use standard input and rds-sink will use standard output. -i interval_seconds An iterative summary of the number and size of messages that are sent and received is written to standard error at this interval. In addition, rds-gen supports the following options: -d address:port Messages are sent to this destination address and port. If this option is specified multiple times then the messages are sent to each destination address in a round-robin fashion. -m message_size Specifies the size of the messages that are sent down the RDS socket. The default message size is 4k. The message size must not be greater than the buffer size. -l total_bytes Specifies the number of bytes that will be sent out the socket before rds-gen exits. If this is not specified and rds-gen was given a source file then it will run until it gets EOF from the file. If no file was given and this option is not specified then rds-gen will send data indefinitely. EXAMPLES
rds-gen on host src sends infinite data to rds-sink on dest who prints out the amount of data it receives every second. $ rds-sink -s dest:22222 -i 1 $ rds-gen -s src:11111 -d dest:22222 Read 100M from /dev/zero on src and write it to /dev/null on dest, printing stats on both sides every minute. $ rds-sink -s dest:22222 -f /dev/null -i 60 $ rds-gen -s src:11111 -f /dev/zero -d dest:22222 -i 60 Watch rds-gen write data as fast as it can into a local black hole because there is no bound receiving socket. $ rds-gen -s src:11111 -d localhost:31337 -i 1 BSD
October 30, 2006 BSD
All times are GMT -4. The time now is 10:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy