02-17-2008
Appending to the first line of a document
Hi all, I'm new to the forums and a total beginner with Unix. I've been given the seemingly simple task of writing a script that asks for two arguments: the first argument being a line of text, the second argument being a document. The script has to take the first argument of text and append it to the specified document in the second argument (no problem), but then the text must be appended to the first line of the document (without using SED or AWK) and I'm confused as to what command I use to do this.
I thought one way around this would be to CAT the first arg and then the second, then save the output to the file noted in the second arg, but because the input and output sources are the same in the second arg, shell doesnt want to know. I have a feeling there is something so simple that I'm missing, but going back over my notes, I can't seem to find what it is that I should know here? Any thoughts?
Perhaps there some way to run VI or EX commands from the shell so that I can paste the input from the first arg into the specified document?
Would really appreciate some advice here! Many thanks.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi, I am a newb as far as shell scripting and SED goes so bear with me on this one.
I want to basically append to each line in a file a delimiter character and the line's line number e.g
Change the file from :-
aaaaaa
bbbbbb
cccccc
to:-
aaaaaa;1
bbbbbb;2
cccccc;3
I have worked... (4 Replies)
Discussion started by: pjcwhite
4 Replies
2. Shell Programming and Scripting
Hello masters.
I have a rather simple problem but its been killing me. I have a file "x" with only 1 line inside it. The line looks something like
Now this is only part of the line. Its actually about 4000 characters. What i need to do is whenever there is a "}", i need to append the next... (4 Replies)
Discussion started by: aismann
4 Replies
3. Shell Programming and Scripting
Hello,
I have got a C file in which I would like to add an include statement of my own.
There are already a few include statements and mine should come right after the last existing one (to be neat).
With grep I can get the lines containing the word 'include' and I guess I should feed the... (7 Replies)
Discussion started by: maxvirrozeito
7 Replies
4. Shell Programming and Scripting
Hi all,
I have to append every alternate line after its previous line. For example if my file has following contents
line 1: unix is an OS
line 2: it is open source
line 3: it supports shell programming
line 4: we can write shell scripts
Required output should be
line1: unix is an OS it is... (4 Replies)
Discussion started by: rish_max
4 Replies
5. Shell Programming and Scripting
I know this has been asked before but I just can't parse the syntax as explained. I have a set of files that has user information spread out over two lines that I wish to merge into one:
User1NameLast User1NameFirst User1Address
E-Mail:User1email
User2NameLast User2NameFirst User2Address... (11 Replies)
Discussion started by: walkerwheeler
11 Replies
6. Shell Programming and Scripting
Hi Experts,
Am relatively new to shell programming so would appreciate some help in this regard.
I am looking at reading from a file, line by line, picking the first word of each line and appending it to the end of the line.
Any suggestions?
INPUT FILE -
3735051 :... (7 Replies)
Discussion started by: hj007
7 Replies
7. UNIX for Dummies Questions & Answers
I have an XML file that I am attempting to create a new text document from it with only one of the pieces of data printed. Here's an example:
Source:
<?xml version="1.0"?>
<Reply Success="TRUE">
<ProfileList NrOfProfiles.DWD="645">
<Profile_0 Name="Test" Description="A... (3 Replies)
Discussion started by: Davinator
3 Replies
8. UNIX for Advanced & Expert Users
How can I run a here document on just one line? I ask, because I need to issue it from C++ as a system() or similar command and for security reasons I don't want to write out a shell script file from the program and run it.
For example, how could I write:
passwd test <<EOF
n3wp3ss... (3 Replies)
Discussion started by: BrandonShw
3 Replies
9. UNIX for Dummies Questions & Answers
Friends,
I am in need to delete files from a directory on a regular basis. I want to place all the files to be deleted in delete .txt file and require a script to delete files, line by line from this delete.txt file. Please help me with this script as am new to unix scripting. (3 Replies)
Discussion started by: fop4658
3 Replies
10. Shell Programming and Scripting
Regarding copy/pasted text of copyright-free book from archive.org (link below), in attempt to expand single-line-break paragraph text (not section headings or paragraph breaks) to wider right margin, Justify or Wrap in LIbreOffice is not working, and Find/Replace the paragraph mark ($) wraps all... (2 Replies)
Discussion started by: p1ne
2 Replies
LEARN ABOUT DEBIAN
ns_sockstrerror
Ns_Sock(3aolserver) AOLserver Library Procedures Ns_Sock(3aolserver)
__________________________________________________________________________________________________________________________________________________
NAME
Ns_BindSock, Ns_GetSockAddr, Ns_SockAccept, Ns_SockAsyncConnect, Ns_SockAsyncConnect2, Ns_SockBind, Ns_SockCloseLater, Ns_SockConnect,
Ns_SockConnect2, Ns_SockListen, Ns_SockListenEx, Ns_SockPipe, Ns_SockSetBlocking, Ns_SockSetNonBlocking, Ns_SockStrError, Ns_SockTimedCon-
nect, Ns_SockTimedConnect2, ns_pipe, ns_sockpair - library procedures
SYNOPSIS
#include "ns.h"
Ns_BindSock(arg, arg)
Ns_GetSockAddr(arg, arg)
Ns_SockAccept(arg, arg)
Ns_SockAsyncConnect(arg, arg)
Ns_SockAsyncConnect2(arg, arg)
Ns_SockBind(arg, arg)
Ns_SockCloseLater(arg, arg)
Ns_SockConnect(arg, arg)
Ns_SockConnect2(arg, arg)
Ns_SockListen(arg, arg)
Ns_SockListenEx(arg, arg)
Ns_SockPipe(arg, arg)
Ns_SockSetBlocking(arg, arg)
Ns_SockSetNonBlocking(arg, arg)
Ns_SockStrError(arg, arg)
Ns_SockTimedConnect(arg, arg)
Ns_SockTimedConnect2(arg, arg)
ns_pipe(arg, arg)
ns_sockpair(arg, arg)
_________________________________________________________________
DESCRIPTION
These functions ...
SEE ALSO
nsd(1), info(n)
KEYWORDS
AOLserver 4.0 Ns_Sock(3aolserver)