Remove end of values in file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remove end of values in file
# 1  
Old 10-23-2009
Remove end of values in file

leviathan:/lcl/apps/Tivoli/netcool/omnibus/bin>more pmonfile.dat
entp_stdby
ot1p_stdby
lawp_stdby


I am wonder how to remove the _stdby from all the values in this dat file using #!/bin/ksh

Thanks!
# 2  
Old 10-23-2009
solution using sed

Here is one way, using sed:

Code:
#!/bin/ksh

pfile="pmonfile.dat"
tmpfile="pmonfile.tmp"

sed -e '1,$s/_stdby$//g' pmonfile.dat > $tmpfile

mv -f $tmpfile $pfile

how's that?
# 3  
Old 10-23-2009
One ksh script coming up:
Code:
#!/bin/ksh
while read line; do
  echo ${line%_stdby}
done <pmonfile.dat >pmonfile.dat.tmp && mv -f pmonfile.dat.tmp pmonfile.dat

# 4  
Old 10-25-2009
Code:
sed 's/_stdby$//' pmonfile.dat

# 5  
Old 10-26-2009
Quote:
Originally Posted by LRoberts
leviathan:/lcl/apps/Tivoli/netcool/omnibus/bin>more pmonfile.dat
entp_stdby
ot1p_stdby
lawp_stdby


I am wonder how to remove the _stdby from all the values in this dat file using #!/bin/ksh

For any shell:

Code:
cut -d_ -f1 pmonfile.dat

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How do delete certain lines alone which are matching with start and end string values in file?

Hi, In my previous post ( How to print lines from a files with specific start and end patterns and pick only the last lines? ), i have got a help to get the last select statement from a file, now i need to remove/exclude the output from main file: Input File format: SELECT ABCD, DEFGH,... (2 Replies)
Discussion started by: nani2019
2 Replies

2. Shell Programming and Scripting

Remove pipes from end of file

Hello all, I have a file like this AA|| BB|| CC|| I want to remove the pipelines (||) from the last occurrance of them in file. that means after removal my file should be like this AA|| BB|| CC how can we achieve this? (2 Replies)
Discussion started by: nnani
2 Replies

3. Shell Programming and Scripting

Get the sum of values in between begin and end in the file

Hi All, test file Begin Script Run at Thu Mar 14 09:24:16 PDT 2013 tst_accounts: ws zip: WS_out_20130313.tar.gz dat: test_20130313.dat count: 63574 loaded: xx pre-merge: xx post-merge: xx timestamp: Thu Mar 14 09:30:42 PDT 2013 tst_accounts: ws zip: WS_out_20130313.tar.gz dat: s_20130313.dat... (6 Replies)
Discussion started by: bmk
6 Replies

4. Shell Programming and Scripting

How to Remove comma as last character in end of last line of file?

how to Remove comma as last charector in end of last line of file: example: input file --------------- aaaaaa, bbbbbb, cccc, 12345, ____________ output file : ----------- aaaaaa, bbbbbb, (6 Replies)
Discussion started by: RahulJoshi
6 Replies

5. Shell Programming and Scripting

End of each line count the values in the file

Hi, How to find the end of character in the file. My requirement should be as below.1 is repeating 1 time ,2 is repeating 3 times... type 1: 1 type 2: 3 type 3: 2 9f680177|20077337258|0|0|0|1000004647916|1 9f680177|20077337258|0|0|0|1000004647916|2 9f680177 20077337258 0 0 0... (5 Replies)
Discussion started by: bmk
5 Replies

6. Shell Programming and Scripting

How to remove new line character at end of file.

I need to remove new line character from end of file. Suppose here are content. a|b|c|d|r a|b|c|d|r a|b|c|d|r <new line> that means file contains 4 lines but data is there in 3 lines. so I want that only 3 lines should be there in file. Please help (20 Replies)
Discussion started by: varun940
20 Replies

7. Shell Programming and Scripting

Print required values at end of the file by using AWK

I am looking help in awk, quick overview. we will get feed from external system . The input file looks like below. Detail Id Info Id Order Id STATUS Status Date FileDetail 99127942 819718 CMOG223481502 PR 04-17-2011 06:01:34PM... (7 Replies)
Discussion started by: dvrbabu
7 Replies

8. Shell Programming and Scripting

remove values of a file one by one from 2nd file and then print the remaining values of 2nd file

Hi all, I have 2 files. One contains only 1 column and other one contains 2 columns, let say 1_col.txt and 2_col.txt respectively. Here, I will try to explain with an example. Input files : 1_col.txt 2_col.txt a a b x a c p ... (5 Replies)
Discussion started by: AshwaniSharma09
5 Replies

9. Shell Programming and Scripting

Remove special char from end of the file

Hi I am working on a bash script and would know how to use cut or sed to remove (F/.M/d h) from a text file. Before 1 text to save (F/.M/d h) after 1 text to save Thanks in advance (5 Replies)
Discussion started by: pelle
5 Replies

10. Shell Programming and Scripting

Remove duplicates from end of file

1/p ---- A B C A C o/p --- B A C From input file it should remove duplicates from end without changing order (5 Replies)
Discussion started by: lavnayas
5 Replies
Login or Register to Ask a Question