Sponsored Content
Full Discussion: ls fed into sed help
Top Forums UNIX for Dummies Questions & Answers ls fed into sed help Post 302574113 by Corona688 on Wednesday 16th of November 2011 01:22:59 PM
Old 11-16-2011
Better to do cat tmp >"$line" since this won't alter file permissions and so forth, which replacing might.

You're forgetting to delete your tmp file.

You also don't need to store the files in the temporary file list.txt, you can pipe them straight into the while loop:

Code:
# CREATE A BACKUP!  You're overwriting your originals, what if something went wrong?
tar -cf ~/sed-backup.tar ./

ls | while read line
do
        sed "/#Text_to_be_deleted/d" "$line" >tmp
        cat tmp>"$line"
done
rm -f tmp


Last edited by Corona688; 11-16-2011 at 02:32 PM..
This User Gave Thanks to Corona688 For This Post:
 

6 More Discussions You Might Find Interesting

1. Cybersecurity

Fed up of Viruses

I am fed up of getting viruses on my computer. They come from other computers on the network and I'm fed up with them. Can anyone reccomend some virus scanning software or something that I can use to prevent my machine from getting viruses? Thanks (3 Replies)
Discussion started by: jacx2
3 Replies

2. UNIX for Dummies Questions & Answers

read user input from within a wile loop that is being fed from below

hi! i need to do a ksh script that uses a wile loop that is fed form below while read line do some things done < myfile inside the while loop i need to read user input to ask the user what he wants to do, but "read" reads the file, and not the standard input while read line do ... (2 Replies)
Discussion started by: broli
2 Replies

3. Red Hat

Help reqd in installing wireless usb on fed 14

Hello all, I am fed up on trying to install my newly purchased usb wireless antenna to my fedora14 machine; so I seek help of all you linux masterminds out there. It worked well in my Win XP. Please help me in setting up it to my Fedora. . Details follows: The device model is : Aztech... (5 Replies)
Discussion started by: gsabarinath
5 Replies

4. UNIX for Dummies Questions & Answers

[ksh93+] Array fed by function is empty when used in main.

I feel that i am missing something obvious but i can't find what is wrong. I have a script that is launching some functions with "&" and each call is feeding the array with a value. When all calls are finished I just want to retrieve the values of that array. It is looking like that : ... (5 Replies)
Discussion started by: bibou25
5 Replies

5. Shell Programming and Scripting

sed and awk giving error ./sample.sh: line 13: sed: command not found

Hi, I am running a script sample.sh in bash environment .In the script i am using sed and awk commands which when executed individually from terminal they are getting executed normally but when i give these sed and awk commands in the script it is giving the below errors :- ./sample.sh: line... (12 Replies)
Discussion started by: satishmallidi
12 Replies

6. Solaris

Replace critical files with errors - pam_UNIX_auth.so.1 & fed

I moved my server while it was running. I was in a hurry. Also it's a bare motherboard with drives in a cage sitting basically on their own. Once I realized how badly I had hurt it doing this, I mounted the board in a tower case I repurposed, mounted the drives, power supply etc. Now the... (1 Reply)
Discussion started by: BillyPrefect
1 Replies
copymsg(9F)						   Kernel Functions for Drivers 					       copymsg(9F)

NAME
copymsg - copy a message SYNOPSIS
#include <sys/stream.h> mblk_t *copymsg(mblk_t *mp); INTERFACE LEVEL
Architecture independent level 1 (DDI/DKI). PARAMETERS
mp Pointer to the message to be copied. DESCRIPTION
copymsg() forms a new message by allocating new message blocks, and copying the contents of the message referred to by mp (using the copyb(9F) function). It returns a pointer to the new message. RETURN VALUES
If the copy is successful, copymsg() returns a pointer to the new message. Otherwise, it returns a NULL pointer. CONTEXT
copymsg() can be called from user or interrupt context. EXAMPLES
Example 1: : Using copymsg The routine lctouc() converts all the lowercase ASCII characters in the message to uppercase. If the reference count is greater than one (line 8), then the message is shared, and must be copied before changing the contents of the data buffer. If the call to the copymsg() function fails (line 9), return NULL (line 10), otherwise, free the original message (line 11). If the reference count was equal to 1, the message can be modified. For each character (line 16) in each message block (line 15), if it is a lowercase letter, convert it to an upper- case letter (line 18). A pointer to the converted message is returned (line 21). 1 mblk_t *lctouc(mp) 2 mblk_t *mp; 3 { 4 mblk_t *cmp; 5 mblk_t *tmp; 6 unsigned char *cp; 7 8 if (mp->b_datap->db_ref > 1) { 9 if ((cmp = copymsg(mp)) == NULL) 10 return (NULL); 11 freemsg(mp); 12 } else { 13 cmp = mp; 14 } 15 for (tmp = cmp; tmp; tmp = tmp->b_cont) { 16 for (cp = tmp->b_rptr; cp < tmp->b_wptr; cp++) { 17 if ((*cp <= 'z') && (*cp >= 'a')) 18 *cp -= 0x20; 19 } 20 } 21 return(cmp); 22 } SEE ALSO
allocb(9F), copyb(9F), msgb(9S) Writing Device Drivers STREAMS Programming Guide SunOS 5.10 27 Jun 1995 copymsg(9F)
All times are GMT -4. The time now is 08:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy