Sponsored Content
Top Forums Shell Programming and Scripting to insert some word somewhere in the line with shell (or perl) Post 302354649 by malcomex999 on Saturday 19th of September 2009 04:57:48 AM
Old 09-19-2009
it would be easier to understand your requirement and assist you if you show it with sample file and desired output.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

insert word in each line of a file

can someone tell me how can I insert a word in front of each line in a file. i tried with sed but didn't managed yet. Is there another command or this one(sed) works? 10x anyway. (7 Replies)
Discussion started by: atticus
7 Replies

2. Shell Programming and Scripting

how to insert text before first line in perl

Hello all im doing simple parsing on text file , but now I need to insert string before the first line of the text file , how can I do that in perl? (3 Replies)
Discussion started by: umen
3 Replies

3. Shell Programming and Scripting

Can a shell script pull the first word (or nth word) off each line of a text file?

Greetings. I am struggling with a shell script to make my life simpler, with a number of practical ways in which it could be used. I want to take a standard text file, and pull the 'n'th word from each line such as the first word from a text file. I'm struggling to see how each line can be... (5 Replies)
Discussion started by: tricky
5 Replies

4. Shell Programming and Scripting

Need to replace the first word of a line if it occurs again in the next line(shell)

Hi folks, have a look into the attachment, i am not familiar with unix, can you please help me in this regard. thanks in advance, :) regards, Geeko (4 Replies)
Discussion started by: geeko
4 Replies

5. Shell Programming and Scripting

Shell script to parse a line and insert a word

Hi All, I have a file like this, data1,data2,,,data5,data6. i want to write a shell script to replace data3 with "/example/string". which means my data file should look like this . data1,data2,example/string],,data5,data6. Could you guys help me to get a sed command or any other command... (8 Replies)
Discussion started by: girish.raos
8 Replies

6. Shell Programming and Scripting

get the fifth line of a text file into a shell script and trim the line to extract a WORD

FOLKS , i have a text file that is generated automatically of an another korn shell script, i want to bring in the fifth line of the text file in to my korn shell script and look for a particular word in the line . Can you all share some thoughts on this one. thanks... Venu (3 Replies)
Discussion started by: venu
3 Replies

7. Shell Programming and Scripting

Perl:How to insert a line to a file.

Hi, Perl is new to me. I am trying to insert a line to a file. Example: I have a file (trial.txt), content: ZZZZ AAA DDDD I am trying to insert CCC below AAA. MY perl command: open (FILE,"+>>C:\\Documents and Settings\\trial.txt\n")|| die "can't open file"; while(<FILE>) { ... (6 Replies)
Discussion started by: SSGKT
6 Replies

8. Shell Programming and Scripting

perl: replace multiple word on a line

Hi All, If I have a line as following: ( MA "vertical" ) How can I convert it to as below: ( BC "horizontal" ) Thanks, --Michael (6 Replies)
Discussion started by: mxn731
6 Replies

9. Linux

How to insert new line in perl

HI, I have a text file in which I have removed all new lines as I would like to introduce a new line at the end of each record in the file. There is no common end line for all the records. A new record will start by *RECORD*. So I want to introduce a new line before this line *RECORD*. So Can... (2 Replies)
Discussion started by: kaav06
2 Replies

10. Shell Programming and Scripting

Sort a line and Insert sorted word(s) in a line

Hello, I am looking to automate a task - which is updating an existing access control instruction of a server and making sure that the attributes defined in the instruction is in sorted order. The instructions will be of a specific syntax. For example lets assume below listed is one of an... (6 Replies)
Discussion started by: sanjayroc
6 Replies
wordexp(3C)															       wordexp(3C)

NAME
wordexp(), wordfree() - perform word expansions SYNOPSIS
DESCRIPTION
performs word expansions and places the list of expanded words into the structure pointed to by pwordexp. The words argument is a pointer to a string containing one or more words to be expanded. The expansions are the same as would be performed by the shell (see sh-posix(1)), if words were the part of a command line representing the arguments to a utility. Therefore, words must not contain an unquoted newline character or any of the unquoted shell special characters or except in the context of shell command substi- tution. If words contains an unquoted comment character, it is treated as the beginning of a token that interprets as a comment indicator, causing the remainder of words to be ignored. The structure type is defined in the header and includes the following members: A used to keep count of words matched by words. A used as a pointer to a list of expanded words. Also a used to indicate the number of slots to reserve at the beginning of stores the number of generated words into Each individual field created during field splitting or path name expansion is a separated word in the list. The words are in order as described in shell word expansions. The first pointer after the last word pointer is a null pointer. The expansion of special parameters (such as $$ or $*) is unspecified. It is the caller's responsibility to allocate the storage pointed to by pwordexp. allocates other space as needed, including memory pointed to by frees any memory associated with pwordexp from a previous call to The flags argument is used to control the behavior of The value of flags is the bitwise inclusive OR of zero or more of the following con- stants, which are defined in Append words generated to the ones from a previous call to Make use of If this flag is set, is used to specify how many null pointers to add to the beginning of In other words, points to null pointers, followed by word pointers, followed by a null pointer. Fail if command substitution is requested. The pwordexp argument was passed to a previous successful call to and has not been passed to The result is the same as if the application had called and then called without Do not redirect stderr to Report error on an attempt to expand an undefined shell variable. The flag can be used to append a new set of words to those generated by a previous call to The following rules apply when two or more calls to are made with the same value of pwordexp and without intervening calls to o The first call must not set All subsequent calls must set it. o All of the calls must set or all must not set it. o After the second and each subsequent call, points to a list containing the following: o Zero or more null pointers, as specified by and o Pointers to the words that were in the list before the call, in the same order as before. o Pointers to the new words generated by the latest call, in the specified order. o The count returned in is the total number of words from all of the calls. o The application can change any of the fields after a call to but if it does, it must reset them to the original value before a subsequent call, using the same pwordexp value, to or with the or flag. If words contains an unquoted newline, parentheses, or curly brackets in an inappropriate context, fails, and the number of expanded words is zero. Unless is set in flags, redirects stderr to for any utilities executed as a result of command substitution while expanding words. If is set, writes messages to stderr if syntax errors are detected while expanding words. If is set, has the same value for each call and the call using a given RETURN VALUE
Upon successful completion, returns zero; otherwise, it returns a nonzero value defined in to indicate the error: One of the unquoted characters parentheses, or braces appears in words in an inappropriate context. Reference to undefined shell variable when is set in flags. Command substitution requested when was set in flags. Attempt to allocate memory failed. Shell syntax error such as unbalanced parentheses or unterminated string. Internal error. If returns the error value and are updated to reflect any words that were successfully expanded. In other cases, they are not modified. AUTHOR
and were developed by OSF and HP. SEE ALSO
sh-posix(1), fnmatch(3C), glob(3C), regexp(5), thread_safety(5). STANDARDS CONFORMANCE
wordexp(3C)
All times are GMT -4. The time now is 03:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy