Sponsored Content
Top Forums UNIX for Dummies Questions & Answers append space to a varaible using sed Post 302142210 by bakunin on Thursday 25th of October 2007 05:00:26 AM
Old 10-25-2007
First off: honestly, this sounds like homework, because a practical reason why anyone woukd want to do this is not conceivable for my simple brain.

Anyways, giving you the benefit of doubt, here is how it goes, the text between "<" and ">" is to be replaced of course:

Code:
var1="abcd"

print - "\"${var1}\""

var1="$(print - "var1" | sed 's/.*/&<....insert 100 spaces here...>/')"

print - "\"${var1}\""

the two "print - ..." - statements are just there to show you the content before and after (surrounded by double quotes).

bakunin
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

append to fle using sed

Hello , I have the folloiwing command : sed -n "$var,$final w $destfile" $sourcefile where : $var - $final represent the range of line numbers to be written in $destfile However I require this command to work in a loop for which i need the sed command to keep appending the output to the... (2 Replies)
Discussion started by: shweta_d
2 Replies

2. Shell Programming and Scripting

append blank space

Hi, I would like to add blank space for fixed length(50) if length of string <30. Scenario: File Size AAA.CSV 123 BB.CSV 134 Expected: File Size AAA.CSV 123 BB.CSV 134 I want append blank space until 30 character. Thanks and Regards, HAA (1 Reply)
Discussion started by: HAA
1 Replies

3. Shell Programming and Scripting

How to append using sed

Hello all, I want to use sed to append a variable stored in $i, how do i do that? $i contains a path to a directory and i want to append it before the result i get from awk statement, before affecting awk results. rite now out put i get from code below is:- The path is:... (2 Replies)
Discussion started by: asirohi
2 Replies

4. Shell Programming and Scripting

sed append in first column

hi, anyone can give a sample command on sed. the text file date list belows; test.txt "a","bbb",123 "b","ccc",234 "c","eee",456 output i need to add these word "xxx" "xxx","a","bbb",123 "xxx","b","ccc",234 "xxx" ,"c","eee",456 thanks in advance, FSP (4 Replies)
Discussion started by: fspalero
4 Replies

5. Shell Programming and Scripting

sed append words

Hi all, I have a file like one two three for five six seven eight ..... Actually i need to append a label to the words that belong to the 2 column and get: one two_label three for five six_label seven eight .... I was trying with sed inside vim but I can't figure out... (9 Replies)
Discussion started by: Dedalus
9 Replies

6. Shell Programming and Scripting

sed append to string

I am trying to replace in multiple files every instance of text that begins with http and add hyperlink characters to it. I can get it to work with the following:sed -e "s/http*.*/<a href=\"&\">&<\/a>/g" * as long as the http text is at the end of the file. I need it to stop at the end of the... (2 Replies)
Discussion started by: numele
2 Replies

7. Shell Programming and Scripting

sed append without using new line

im trying to append to the end of the line using sed but I want to do it without creating a new line the text to which I want to append is all in capital letters. I want to do something like this: LINE]Foo but when I do this: //a\ ] Foo it prints foo on a new line: LINE ]Foo ... (11 Replies)
Discussion started by: mrjavoman
11 Replies

8. Shell Programming and Scripting

Append variable value with sed

I have a requirement where I need to add a variable value based on a pattern match. When I try this it works: sed '/IS_ETL_DEV/a\ ABCD' File1.txt > File1.tmp Now I want to replace IS _ETL_DEV with a variable like $Pattern and replace the values ABCD with a variable $Var the value "$$XYZ=1".... (4 Replies)
Discussion started by: vskr72
4 Replies

9. UNIX for Dummies Questions & Answers

To flat file, append null or space if its length is less than 10

Hi, We receive flat files with fixed width data Now our goal is append from right null or space to each record if the lenght of the record is less than for example 10. for example 123 45 6 0 123 45 123 45 6 123 and output should be 123 45 6 0 123 45**** 123 45 6**... (7 Replies)
Discussion started by: shharrath
7 Replies

10. Solaris

Passing a varaible to sed issue

I am unable to make it work. I tried dbl quotes ...etc. Nothing works. I am trying to replace value in an XML file to current system date/time. Here is my code: NTIMESTAMP=`date '+%m%d%Y%H%M%S'` sed -e 's|<TIMESTAMP>\{1,\}|<TIMESTAMP>$NTIMESTAMP|g' $QLOG Input data sample: ... (5 Replies)
Discussion started by: mrn6430
5 Replies
STAPDYN(8)						      System Manager's Manual							STAPDYN(8)

NAME
stapdyn - systemtap dyninst runtime SYNOPSIS
stapdyn [ OPTIONS ] MODULE [ MODULE-OPTIONS ] DESCRIPTION
The stapdyn program is the dyninst back-end of the Systemtap tool. It expects a shared library produced by the front-end stap tool, when run with --dyninst. Splitting the systemtap tool into a front-end and a back-end allows a user to compile a systemtap script on a development machine that has the debugging information (need to compile the script) and then transfer the resulting shared objevct to a production machine that doesn't have any development tools or debugging information installed. Please refer to stappaths(7) for the version number, or run rpm -q systemtap (fedora/red hat) apt-get -v systemtap (ubuntu) OPTIONS
The stapdyn program supports the following options. Any other option prints a list of supported options. -v Verbose mode. -V Print version number and exit. -w Suppress warnings from the script. -c CMD Command CMD will be run and the stapdyn program will exit when CMD does. The '_stp_target' variable will contain the pid for CMD. -x PID The '_stp_target' variable will be set to PID. -o FILE Send output to FILE. If the module uses bulk mode, the output will be in percpu files FILE_x(FILE_cpux in background and bulk mode) where 'x' is the cpu number. This supports strftime(3) formats for FILE. -C WHEN Control coloring of error messages. WHEN must be either "never", "always", or "auto" (i.e. enable only if at a terminal). If the op- tion is missing, then "auto" is assumed. Colors can be modified using the SYSTEMTAP_COLORS environment variable. See the stap(1) manual page for more information on syntax and behaviour. var1=val Sets the value of global variable var1 to val. Global variables contained within a script are treated as options and can be set from the stapdyn command line. ARGUMENTS
MODULE is either a module path or a module name. If it is a module name, the module will be looked for in the following directory (where 'VERSION' is the output of "uname -r"): /lib/modules/VERSION/systemtap $ stap --dyninst -p4 -m mod1 -e 'global var1="foo"; probe begin{printf("%s ", var1); exit()}' Running this with an additional module argument: $ stapdyn mod1.so var1="HelloWorld" HelloWorld Spaces and exclamation marks currently cannot be passed into global variables this way. EXAMPLES
See the stapex(3stap) manual page for a collection of sample scripts. Here is a very basic example of how to use stapdyn. First, use stap to compile a script. The stap program will report the pathname to the resulting module. $ stap --dyninst -p4 -e 'probe begin { printf("Hello World! "); exit() }' /home/user/.systemtap/cache/85/stap_8553d83f78c_265.so Run stapdyn with the pathname to the module as an argument. $ stapdyn /home/user/.systemtap/cache/85/stap_8553d83f78c_265.so Hello World! SAFETY AND SECURITY
Systemtap, in DynInst mode, is a developer tool, and runs completely unprivileged. The Linux kernel will only permit one's own processes to be accessed, which is enforced by the ptrace(2) system call. See the stap(1) manual page for additional information on safety and secu- rity. SEE ALSO
stap(1), stapprobes(3stap), stap-server(8), staprun(8), stapex(3stap) BUGS
Use the Bugzilla link of the project web page or our mailing list. http://sourceware.org/systemtap/, <systemtap@sourceware.org>. STAPDYN(8)
All times are GMT -4. The time now is 06:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy