![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Delete blocks of lines from text file | nrbhole | Shell Programming and Scripting | 4 | 12-19-2007 06:17 AM |
| Delete a block of text delimited by blank lines when pattern is found | gleu | Shell Programming and Scripting | 17 | 12-16-2007 11:30 PM |
| Delete lines containing text with sed | umen | Shell Programming and Scripting | 2 | 08-01-2006 04:24 AM |
| Delete specific lines in a text file | dniz | High Level Programming | 9 | 08-08-2005 08:30 AM |
| delete blank lines or lines with spaces only | vascobrito | UNIX for Dummies Questions & Answers | 3 | 01-13-2004 07:36 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Hi
I want to delete first five and last five lines in text files without opening the file and also i want to keep the same file name for all the files. Thanks in advance!!! Ragav |
|
||||
|
shell
Hi,
This one is used to delete certain number of line from the head and end of file in a given direcotory. Hope it is useful for you. Quote:
|
|
||||
|
Hi,
I tried with ur script.Its giving error msg as follows: xpr:error opening "1, " for input no such file or directory. I have tried with following script (assume i have A.txt,B.txt in dir path): echo "ur dir path:" read dirp cd $dirp for i in * do awk 'FNR>5' $i > $i.new done With this i am able to delete first five lines.same way i want to delete last five lines also. Any suggestions .... Thanks in advance. Note : one more doubt why am i getting A.txt~.new,B.txt~.new even my *.sh,*.txt files are not opened? I have seen the same scenario in MS word when you open one Word document until you close that doc will get one temp XXX.doc~.tmp something. Ignore my silly doubts ![]() Cheers, Ragavendran |
|
||||
|
Ragavendran, see if this helps
team$ cat numbers
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 team$ team$ cat lines.sh #!/usr/bin/ksh echo "Enter No.of lines to remove from TOP : " read top echo "Enter No.of lines to remove from BOTTOM :" read bottom total=`wc -l < numbers` endval=`expr $total - $bottom` startval=`expr $top + 1` echo "**** Showing lines $startval -- $endval **** \n" sed -n ${startval},${endval}p $1 team$ team$ lines.sh numbers Enter No.of lines to remove from TOP : 4 Enter No.of lines to remove from BOTTOM : 4 **** Showing lines 5 -- 11 **** 5 6 7 8 9 10 11 team$ put it in for loop to process all the files . ![]() |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|