second opinion on sed script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers second opinion on sed script
# 1  
Old 06-28-2005
second opinion on sed script

i'm trying to figure out a script that uses sed, and i'm not totally sure if it does what I think it does.
The script...
- takes in 3 inputs, $1, $2 are names. $3 is a file.
- filename is a file.

Here is what I'm trying to figure out:

cat $3 | grep "id17" > var2
sed "s|@@.*||g" var2 > var3
sed "s/^/filename $1 $2 /g" var3 > $3x
chmod a+x $3x
$3x

so does this mean that...
1. it will cat $3 and then pipe it into grep. Grep will find all the lines that contain id17, and then output it to file var2.
2. sed will substitute all words in var2 that contain @@ in the word. It will do this for the entire line. Then it will output the results to var3.
3. sed will substitute all words in var3 ,that begin with $1 and $2, with the filename. It will do this for the entire line. Then it will output the results to a file that has the same name as file $3, but with an x in it.
4. the file $3x will be chmod to be executable.
5. run file $3x.

thanks,
gammaman
# 2  
Old 06-28-2005
sed "s/^/filename $1 $2 /g" var3 > $3x

sed will replace the beginning of the line with "filename $1 $2 ". In other words, this gets prepended to the line.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

[Opinion] A Public Answer To Rob McNelly

Why Do We Need Root on the HMC? In this article in IBMSystems Magazine Rob McNelly asked the question Why Don't We Have Root on the HMC? and he goes on to justify why we indeed shouldn't have root - kinda. I think his arguments are not as valid as he perhaps thinks they are and what's more... (11 Replies)
Discussion started by: bakunin
11 Replies

2. Shell Programming and Scripting

Opinion on an easy shell script (mv)

:wall:I've this simple code: STF=/opt/aaa cat $STF | nice sort -u > $STF.new && mv $STF.new $STF Which works until today. What happened is that this script has been corrupted the FS, so I've to use fschk to repair the filesystem. I presume the move command executed just a little too early... (1 Reply)
Discussion started by: accolito
1 Replies

3. What is on Your Mind?

Something in my mind - what's your opinion ?

Dear Forum staff / Advisors / members , I am having something in my mind, about Linux / Unix possible Interview questions collections, I guess if I post them here,which might be useful for our members and for students, and in meantime we can discuss also about those questions, what's your... (4 Replies)
Discussion started by: Akshay Hegde
4 Replies

4. UNIX for Advanced & Expert Users

Expert opinion on iptables/torrents

Hello all, I want to deny any torrents passing thru linux box that are NOT encrypted. My ISP is doing packet inspection and gives warnings. I'd like to allow torrents when client sets encryption. Any thoughts? (5 Replies)
Discussion started by: darkman_hr
5 Replies

5. UNIX for Advanced & Expert Users

Expert Opinion

This perhaps does not belong in ths category; apologies, however, we have a heated debate going and your input will decide the result. Should UNIX (HP, AIX, etc) be rebooted following a monthly cycle (Every month, or a qtr, etc.). We have some UX admins (grumps) who say they have seen a UX... (6 Replies)
Discussion started by: rsheikh
6 Replies

6. UNIX and Linux Applications

Opinion on modification for SMARTMON

Hello, I get the following in one of my error logs: Device /dev/sda, SATA disks accessed via libata are not currently supported by smartmontools. When libata is given an ATA pass-thru ioctl() then an additional '-d libata' device type will be added to smartmontools. --------------- ... (1 Reply)
Discussion started by: mojoman
1 Replies

7. UNIX for Dummies Questions & Answers

Opinion on modification for SMARTMON

Hello, I get the following in one of my error logs: Device /dev/sda, SATA disks accessed via libata are not currently supported by smartmontools. When libata is given an ATA pass-thru ioctl() then an additional '-d libata' device type will be added to smartmontools. --------------- I... (0 Replies)
Discussion started by: mojoman
0 Replies

8. Post Here to Contact Site Administrators and Moderators

Opinion

Hi, I am new at this site and at unix. I was reading some answers that the administrators and moderators have posted to others, and sometimes I feel like their a little sarcastic. I am asking just to be patient to me, I know nothing about unix but I do want to learn, and I think that positive... (7 Replies)
Discussion started by: HN19
7 Replies

9. Solaris

Your Opinion requested

Ladies/Gentlemen, I am looking for a web-based tool to keep track of my Sun inventory. The following list of fields are fields I would like to store: Root Passwd (needs to be secure) / Hostid / Console Port / IP Address / Platform / Application / Hostname . . . you get the point. Do any of... (4 Replies)
Discussion started by: pc9456
4 Replies

10. UNIX Desktop Questions & Answers

Need your help and opinion

Hey all, I'm brand new to Unix/Linux and have a couple of questions. I own a small education/consulting company that has a staff of approx. 50 employees. Most our work is geared towards the office-style environment (i.e. Word, Excel, Powerpoint, etc.). There are also some C and Java programmers... (4 Replies)
Discussion started by: dennie1
4 Replies
Login or Register to Ask a Question