How I can replace this command --need help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How I can replace this command --need help
# 1  
Old 06-21-2007
How I can replace this command --need help

Hi,

can I delate first line in a file without opening a file.

Normal unix "sed -i '1d' $path/cash.log" command is working fine, but my windows application not supporting latest version of sed, I also tried to download latest version of sed.exe but failed to find one.

I am in a process of implement a buffer mechanism using following script

#!/bin/sh
path=C:/APPS/Tivoli/bin/w32-ix86/TME/TEC/scripts
set -x
exec 2> $path/SMS_LOG1.log
Cash_count=`more $path/cash.log |wc -l`
while [ "$Cash_count" != "0" ]
do
sms=`head -1 $path/cash.log`
echo "#MSG#$sms" >>$path/output
sleep 5
sed -i '1d' $path/cash.log
Cash_count=`more $path/cash.log |wc -l`
#echo "Cash_count: $Cash_count"
done < $path/cash.log


Please help me on this.


Thanks in advance
Regards
Sudhish
# 2  
Old 06-21-2007
Code:
awk ' NR > 1 { print > "newfile.back" }' currentfile

# 3  
Old 06-21-2007
but I what to delete the first line

Hi,

awk ' NR > 1 { print > "newfile.back" }' currentfile

It is working fine, but I what to delete the first line since it is loop command I cant replace the file.
Thanks in advance

Regards
Sudhish
# 4  
Old 06-21-2007
Code:
tail +2 input_file > output_file

# 5  
Old 06-21-2007
Code:
It is working fine, but I what to delete the first line since it is loop command I cant replace the file.
Thanks in advance


If you had to process within a loop,
this might help,

awk command;
( you have the new file )
mv new_file old_file

Last edited by matrixmadhan; 06-21-2007 at 10:14 AM.. Reason: typo
# 6  
Old 06-21-2007
Deletion of first line is the problem

Hi,
Let me explain my requirement
1. $path/cash.log is a cash file, I can't rename it because it content is loaded by another script
2. This script will send SMS until cash.log file become empty also it will continue check for the messages, start sending sms as soon as the message comes
3. Script can only take first line of the cash.log file and send SMS
4. Then I have to delete the first line, other wise script will always send same message only

Deletion of first line is the problem

Thanks in advance
Sudhish
# 7  
Old 06-21-2007
Deletion of first line is the problem

Hi,

Let me explain my requirement

1. $path/cash.log is a cash file, I can't rename it because it content is loaded by another script
2. This script will send SMS until cash.log file become empty also it will continue check for the messages, start sending sms as soon as the message comes
3. Script can only take first line of the cash.log file and send SMS
4. Then I have to delete the first line, other wise script will always send same message only

Deletion of first line is the problem

Thanks in advance
Sudhish
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed Command to replace particular value.

Hi , My input file contain : list = 3 14 15 10 9 11 12 18 19 20 21 22 23 24 25 26 6 1 2 3 4 5 7 8 16 17 27 28 30 29 Expected output : list = 0 0 0 0 0 0 0 18 0 20 0 0 0 0 0 0 6 0 0 3 4 0 0 0 0 0 0 0 0 0 I want to keep the 8,10,16,17,22 value from the list and put 0 on rest of the... (9 Replies)
Discussion started by: Preeti Chandra
9 Replies

2. Shell Programming and Scripting

sed replace command

Hi. I need to append/prefix an & character to every 'single' & character (not when there are 2 or more grouped together) I find in a file. I can do it using this cmd: cat ${file} | sed -e 's/&/&&/g' > ${new_file} How can I modify this to ensure I only replace single &'s and not operate... (11 Replies)
Discussion started by: user052009
11 Replies

3. UNIX for Dummies Questions & Answers

Global replace command help

Hello - I am trying to use a global replace command but its not working. Here is the cmd I am using in vi: :%s/OLD/NEW/g However, in my "NEW" I already have a "/" which is not making the replace work: :%s/mytestscript.com:33232/mytestscript:70245/test.com/g the... (2 Replies)
Discussion started by: DallasT
2 Replies

4. UNIX for Dummies Questions & Answers

Replace command

Hi , I have a sequence which looks like this Lsat01000001 Lsat01000002 Lsat01000003 .. Lsat01000999 .. Lsat01100001 Lsat01278544 i want my output to look like this: seq1 seq2 seq3 ... seq999 (1 Reply)
Discussion started by: siya@
1 Replies

5. Shell Programming and Scripting

Please help replace character command

hi i have log : i want remove some char become like this: anybody can help me ? (7 Replies)
Discussion started by: justbow
7 Replies

6. Shell Programming and Scripting

find and replace command

Hi, i used to do on soalris box but in linux box i am not able to do advice is appreciated uname -a Linux intranet 2.4.20-pre3 #1 Tue May 6 17:55:35 IST 2008 i686 unknown $ find /usr/local/ -type f | xargs perl -pi -e 's/172.16.1.14/172.16.1.27/g' Can't remove /usr/local/bin/dbhome:... (1 Reply)
Discussion started by: prakash.gr
1 Replies

7. Shell Programming and Scripting

problem with replace command with tr

I have a sample file like this 7829885 7831552 + 1 1667, 0, 35934936 35937087 - 2 1281,870, 0,1281, I would like to replace values starts with comma with just value like 0, to 0 or 1667, to 1667. I can do with this by using tr -d '0,' '0' <file But the... (2 Replies)
Discussion started by: repinementer
2 Replies

8. UNIX for Dummies Questions & Answers

find and replace command in one line using one command

Hi, I have a entry in the file as ::BSNL GUJARAT::India::OUT::NAT::REWEL::POSTPAID::919426199995 if u see this, i have the delimiter as :: , all i want is to replace "::" as ":" so how to do that.. pls help thanks (10 Replies)
Discussion started by: vasikaran
10 Replies

9. UNIX for Dummies Questions & Answers

vi command - replace

Hi, Given a long text file. How can I replace all full stops- with semicolon thanks, tictactoe (1 Reply)
Discussion started by: tictactoe
1 Replies

10. UNIX for Dummies Questions & Answers

Command to replace character

I've been googling for the following for the past few weeks several times, but haven't yet come across something that I could easily grasp. Can someone point me in the right direction please? I'm trying to replace a character in file names, i.e. the character is a period, and I want to replace... (5 Replies)
Discussion started by: HLee1981
5 Replies
Login or Register to Ask a Question