![]() |
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 |
| not able to delete a file | dr46014 | UNIX for Dummies Questions & Answers | 1 | 05-14-2008 10:51 PM |
| Why can't I delete this file? | tphyahoo | UNIX for Dummies Questions & Answers | 3 | 07-17-2006 04:35 PM |
| how to delete record in file data with index in another file? | zhynxn | Shell Programming and Scripting | 0 | 07-06-2006 12:03 AM |
| i want to delete a file based on existing file in a directory | srivsn | Shell Programming and Scripting | 3 | 04-11-2006 04:38 AM |
| Get file from source server and delete the ftp file | lweegp | Shell Programming and Scripting | 3 | 10-17-2005 02:53 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
maybe I said this wrong on my post. I need to delete the FIRST 20k (size) from a file (lets say I don't know the file size) and the name of the file is test.log. How do go about deleting the first 20k from a file size that I do not know.
D |
|
||||
|
Quote:
The block size is defined in k. It says to skip the first 20 blocks, so 20 k. The rest (all after the first 20k) is copied. |
|
||||
|
Quote:
With 1 argument you can specify the name of the file from which you want to cut of the first 20k, the new file will have the same name with ".new" added. Code:
#!/usr/bin/ksh
dd if=${1} of=${1}.new bs=1k skip=20
You would run it like "./cut20k-v1.sh <file>" E.g. Code:
./cut20k-v1.sh testfile You could create a script which takes 2 arguments. The first argument would be the name of the file from which you would like to cut off the first 20k and the second argument would be the name of the file with the first 20k missing. Code:
#!/usr/bin/ksh
dd if=${1} of=${2} bs=1k skip=20
You would run it like "./cut20k-v2.sh <infile> <outfile>" E.g. Code:
./cut20k-v2.sh testfile resultfile |
|
||||
|
I am new to scripting and am trying to do a similar thing;
I would like to take the first 20k out of a file, leave the rest of the file intact then output that 20k to a new file. I am not sure how to do this.. Thanks for the help! |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|