06-14-2006
Hi Shereenmoter,
I got exactly the same error:
sed: -e expression #1, char 3: Extra characters after command
This is what ive written so far:
#Get the number of lines in the file
MyVar="`wc -w NewFile | awk '{print $1}'`"
#Get The middle of the file
Middle=$ expr $MyVar / 2
#sed -e "${Middle}a $Text" NewFile
sed ${Middle}i'\Chief' NewFile
N.B. Unbeliever, i know this is still not using your method for finding the middle of the file, just testing stuff at the moment.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I need to add a new lines with certain data, to an existing file, every 5 lines in the file.
There is no way to find any distinct charater pattern so
I will have to do a line count and then insert the new line.
I think using awk or sed is what I need to do.
Any help is appreciated.
Kunder (2 Replies)
Discussion started by: kunder
2 Replies
2. Shell Programming and Scripting
Hi,
I have tried many times to add the string into the first line of the file or the middle of the file but could not find the solution.
I first tried by
$echo "paki" >> file
This code only append paki string at the end of file "file" but how can i add this "paki" into the first line or... (5 Replies)
Discussion started by: ali hussain
5 Replies
3. Shell Programming and Scripting
i want to add a string in a very top of a file without using VI or SED or AWK
this is what ive done:
(echo '0a'; echo 'LINE OF TEXT'; echo '.'; echo 'wq') | ed -s myfile
to add astrng right in the middle i could have count the lines of the file and just chenge the address.
... (6 Replies)
Discussion started by: ciroredz
6 Replies
4. Shell Programming and Scripting
Can anyone help me pls? I want to add a text into the middle of file.
I've writtenthe following script
text to add="$1"
file="$2"
lines=$(wc -l $2)
half_lines=$(expr $lines / 2)
head -$half_lines $2 > temp
echo "text to add" >> temp
((half_lines=$half_lines + 1))
tail -$half_lines $2... (6 Replies)
Discussion started by: relle
6 Replies
5. Shell Programming and Scripting
I've got a configuration file that is filled with xml text statements for example:
<...../>
<...../>
<...../>
<data id="java-options" value="-server -Djava.security.policy..../>
<...../>
<...../>
<...../>
I want to write a korn shell script that will go to this specific line and add a... (2 Replies)
Discussion started by: progkcp
2 Replies
6. Shell Programming and Scripting
I am trying to strip out certain characters from a string on both (left & right) sides. For example, line=see@hear|touch, i only want to echo the "hear" part. Well i have tried this approach:
line=see@hear|touch
templine=${line#*@} #removed "see@"
echo ${templine%%\|*} #removed... (4 Replies)
Discussion started by: mcoblefias
4 Replies
7. UNIX for Dummies Questions & Answers
Hello all!
I'm trying to put together a small script that will take in a file name and attach a datestamp to the end of it (but before the file type extension).
To illustrate...
Before:
filename.txt
anotherfilename.txt
After:
filename_20090724.txt
anotherfilename_20090724.txt
... (7 Replies)
Discussion started by: jisoo411
7 Replies
8. Linux
my file input is with tab as delimiter, and in every line, there would be a skip of line with an unexcepted newline breaker. I'd like to remove this \n and put the information in the same line.
INPUT
a1 b1b2 c1
c2 d1
a2 b3 c3 d4
OUTPUT
a1 b1b2 c1c2 ... (9 Replies)
Discussion started by: kinkichin
9 Replies
9. UNIX for Dummies Questions & Answers
Hi Folks!
I hope you can help me figure this out. I need to print a record which contains the contents of a config file. The contents of the config file should be found within the 21st and the 30th position of the fixed width reference file.
Config File:
aaaa
bbbb
cccc
Reference... (3 Replies)
Discussion started by: kokoro
3 Replies
10. UNIX for Beginners Questions & Answers
My sample file is variable length, with out any field delimiters. It has min of 18 chars length and the 'CRLF' is potentially between 12-14 chars. How do I replace this with a space? I still want to keep end of record, but just want to remove these new lines chars in the middle of the data.
... (7 Replies)
Discussion started by: chandrath
7 Replies
LEARN ABOUT DEBIAN
cdkparseposition
cdk_params(3) Library Functions Manual cdk_params(3)
NAME
cdk_params - Cdk command-line parsing
SYNOPSIS
cc [ flag ... ] file ... -lcdk [ library ... ]
#include <cdk.h>
int CDKparamNumber (
CDK_PARAMS *params,
int option);
int CDKparamNumber2 (
CDK_PARAMS *params,
int option,
int missing);
char * CDKparamString (
CDK_PARAMS *params,
int option);
char * CDKparamString2 (
CDK_PARAMS *params,
int option,
char *missing);
void CDKparseParams (
int argc,
char **argv,
CDK_PARAMS *params,
char *options);
int CDKparsePosition (
char *string);
int CDKparamValue (
CDK_PARAMS * params,
int option,
int missing);
DESCRIPTION
These are a set of functions used to implement the command-line utilities and demonstration programs for Cdk. Rather than set the pro-
grams' options at initialization, they construct a simple database which holds the common parameters using CDKparseParams().
AVAILABLE FUNCTIONS
CDKparamNumber
Retrieves an integer (or boolean) option value from the parsed command-line.
CDKparamNumber2
Retrieves an optional integer (or boolean) value from the parsed command-line. If the command line option is not present, the missing
value is used.
CDKparamString
Retrieves a string option value from the parsed command-line.
CDKparamString2
Retrieve an optional string option value from the parsed command-line.
CDKparamValue
Retrieve an integer (or boolean) option value from the parsed command-line.
CDKparseParams
Parse the given argc/argv command-line, with the options passed to getopt()'s 3rd parameter.
CDKparsePosition
Parse the string as one of CDK's positioning keywords, or an actual position.
SEE ALSO
cdk_position (3), getopt (3)
cdk_params(3)