Inserting 1st arg into middle


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Inserting 1st arg into middle
# 1  
Old 04-13-2007
CPU & Memory Inserting 1st arg into middle

I wrote a script like
#!/bin/bash
echo $1 > temp
cat $2 >> temp
mv temp $2

now I have problem appending the above script(only using bash shell) so that it now inserts the first argument into the middle of the file.

I have tried using $(('wc -l < file' / 2 ))
but invain so could any one help.
# 2  
Old 04-13-2007
Boris,
You are breaking the rules by posting the same posting twice.
The other one was:
"How to insert the 1st arg into the middle of the file"
This is not allowed.
# 3  
Old 04-13-2007
Shell Life is correct and this thread is now closed.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script too many arg's

I have a simple bash script on RHEL that works fine when there is one file but when it finds multiple files of same condition I get too many args error. for i in * do if ;then echo "no files to move" exit 0 fi if ; then ... (10 Replies)
Discussion started by: jcalisi
10 Replies

2. Shell Programming and Scripting

Copy from/to file, if arg 'ok'

Hello, I've just started with shell scripting, and I need som assistance! Basicly what I want to do is copy names from one file to another, when running the scrip the user should be asked about the status of these names. Let me demonstrate: file: Name: John, Gender: male Name: Jane,... (6 Replies)
Discussion started by: klskl
6 Replies

3. UNIX for Dummies Questions & Answers

Arg list too long

Hello All, I am trying to find a file name with .sh exention from a list of .dat files inside a directory. find /app/folder1/* -name '*.dat'| xargs grep '.sh' ksh: /usr/local/bin/find: arg list too long Please help me finding the command. Thanks (3 Replies)
Discussion started by: tkhan9
3 Replies

4. UNIX for Dummies Questions & Answers

Space in a arg

Hi, When i am running a script it considers the below as mulitple arguments. There is any command which can ignore the spaces. I tried by using sed like below to ignore but it doesnt work. sed 's/ /\\ /g'100% Haddock Fillets Battered 500G-small.gif ~vino (3 Replies)
Discussion started by: vino_hymi
3 Replies

5. Programming

warning: int format,pid_t arg (arg 2)

I try following code under Solaris10,like follows: int glob = 6; int main(void) { int var; pid_t pid; var = 88; printf("before vfork\n"); if ((pid = vfork()) < 0) { err_sys("vfork error"); } else if (pid == 0) { glob++; var++; _exit(0); } ... (1 Reply)
Discussion started by: konvalo
1 Replies

6. Shell Programming and Scripting

How to insert the 1st arg into the middle of the file

I wrote a script like #!/bin/bash echo $1 > temp cat $2 >> temp mv temp $2 now I have problem appending the above script(only using bash shell) so that it now inserts the first argument into the middle of the file. I have tried using $(('wc -l < file' / 2 )) but invain so could any one... (4 Replies)
Discussion started by: boris
4 Replies

7. UNIX for Dummies Questions & Answers

ls -t arg list too long

echo dirname/filename* | xargs ls -t As a substitute doesn't give the results desired when I exceed the buffer size. I still want the files listed in chronological order, unfortunately xargs releases the names piecemeal...does anyone have any ideas? :( (4 Replies)
Discussion started by: CSU_Ram
4 Replies

8. UNIX for Advanced & Expert Users

arg list too long

Does anyone have a solution for arg list too long error. I have got this from the web but I fail to make any sense out of it Thanks enc (8 Replies)
Discussion started by: encrypted
8 Replies

9. UNIX for Dummies Questions & Answers

arg list too long

I do ls -l ABC*, I get arg list too long message. This will not happen if ABC* has small no of files I believe 4000 files is limit. Any way of avoiding this. I even tried like this for i in `ls -l ABC*` do echo $i done Same problem. Any solution would be great. I am on HP-UX... (5 Replies)
Discussion started by: vingupta
5 Replies
Login or Register to Ask a Question