06-09-2017
Good, and if printf doesn't mess it up, neither will sed. The shell does not differentiate between the two, substitution happens before sed or printf is run.
Hit the up arrow on your console to repeat the 'printf' command, delete the 'printf "%s\n"', insert 'sed' in its place, go to the end, add '< inputfile > outputfile' and hit enter.
If that doesn't work, show exactly what you do and exactly what result you get, word for word, letter for letter, keystroke for keystroke. You're doing some substitution or escaping somewhere which causes $ to be taken literally. Notably, you can't store $ in a variable and expect it to be evaluated later.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi folks,
I'm looking for a solution to pass variables to a sed-command. I'm reading a lot of threats and also the q&a "How can I use a variable in sed?". None of these commands works. I'm using AIX 5.2.
I want to do the following:
NUMBER=` echo 38341` | sed -n '/$NUMBER/p'
an obtained... (3 Replies)
Discussion started by: jfisch
3 Replies
2. Shell Programming and Scripting
I m trying to pass variable to sed.
export var=140920060731
sed -e '/$var/d' file
but no luch so far..? any body has any idea abt it
Is there any way to pass variable to SED?
Thanks ,
Manish (2 Replies)
Discussion started by: Manish Jha
2 Replies
3. UNIX for Dummies Questions & Answers
Hi,
I would like to append 100 blank spaces to a variable using sed.
eg:
var1=abcdef
Could anyone advice???
thanks,
Sumith (3 Replies)
Discussion started by: sam99
3 Replies
4. Shell Programming and Scripting
Hi Folks,
How can I make the following to work from a korn shell?
old="OLDSTRING"
new="NEWSTRING"
file="myfile.txt"
sed -n 's/$old/$new/gp' $file
Thanks in advance
rogers42 (3 Replies)
Discussion started by: rogers42
3 Replies
5. Shell Programming and Scripting
Dear All,
I want to print a file.
First I tried with this
sed '2q;d' filename
it worked. But when i put following it is not working
x=2;
sed '$xq;d' filename
Would any one suggest how to pass the variable? (7 Replies)
Discussion started by: saifurshaon
7 Replies
6. UNIX for Dummies Questions & Answers
Hi Everyone!!
Hey i created a SFTP function to FTP the file from unix to Linux.
I need to FTP the 48 files from unix to linux.
IP=$1
Userid=$2
Prikeypath=$3
SrcPath=$4
DstPath=$5
Files=$6
BATCHFILE=sftp.batch.$$
LOGFILE=sftp.log.$$
#Compose batch file & pass as argument to the... (1 Reply)
Discussion started by: bobprabhu
1 Replies
7. Shell Programming and Scripting
Hi Experts,
I am passing current month & day (i.e. 'Jul 21') from script aaa.ksh to zzz.ksh. The value 'Mon DD' is being used in zzz.ksh.
Problem: If I pass 'Mon DD' value manually to zzz.ksh i.e.
/test/zzz.ksh 'Jul 21'
it works fine. However, if I pass value from aaa.ksh, it does... (2 Replies)
Discussion started by: dipeshvshah
2 Replies
8. Shell Programming and Scripting
Hi Gurus,
I have small issue...
I used to pass the passwd for sudo commands like below,
gzcat ~/passwd.gz | sudo su - <villin> >> eof
------
-----
------
eof
And it was able to login into "villin" sudo account successfully. But now, I'm using the same in another script for the... (2 Replies)
Discussion started by: raghu.iv85
2 Replies
9. Shell Programming and Scripting
Hi,
I'm trying to check if methods specified in a class have been added to the corrosponding interface.
My code below is giving me the following errors:
grep: function: No such file or directory
grep: import($zipfile): No such file or directory
grep: function: No such file or... (1 Reply)
Discussion started by: racshot65
1 Replies
10. UNIX for Dummies Questions & Answers
Hi,
I want to pass value of a variable track_line which is the line number to sed. Sed should print the lines starting from track_line till the last
line of the file. I tried the below command but it is not working.
sed -n '${track_line},$p' latest_log_file
I tried using the below too but... (1 Reply)
Discussion started by: nitinupadhyaya8
1 Replies
LEARN ABOUT DEBIAN
athena-jot
JOT(1) General Commands Manual JOT(1)
NAME
jot - print sequential or random data
SYNOPSIS
jot [ options ] [ reps [ begin [ end [ s ] ] ] ]
DESCRIPTION
Jot is used to print out increasing, decreasing, random, or redundant data, usually numbers, one per line. The options are understood as
follows.
-r Generate random data instead of sequential data, the default.
-b word
Just print word repetitively.
-w word
Print word with the generated data appended to it. Octal, hexadecimal, exponential, ASCII, zero padded, and right-adjusted repre-
sentations are possible by using the appropriate printf(3) conversion specification inside word, in which case the data are inserted
rather than appended.
-c This is an abbreviation for -w %c.
-s string
Print data separated by string. Normally, newlines separate data.
-n Do not print the final newline normally appended to the output.
-p precision
Print only as many digits or characters of the data as indicated by the integer precision. In the absence of -p, the precision is
the greater of the precisions of begin and end. The -p option is overridden by whatever appears in a printf(3) conversion following
-w.
The last four arguments indicate, respectively, the number of data, the lower bound, the upper bound, and the step size or, for random
data, the seed. While at least one of them must appear, any of the other three may be omitted, and will be considered as such if given as
-. Any three of these arguments determines the fourth. If four are specified and the given and computed values of reps conflict, the
lower value is used. If fewer than three are specified, defaults are assigned left to right, except for s, which assumes its default
unless both begin and end are given.
Defaults for the four arguments are, respectively, 100, 1, 100, and 1, except that when random data are requested, s defaults to a seed
depending upon the time of day. Reps is expected to be an unsigned integer, and if given as zero is taken to be infinite. Begin and end
may be given as real numbers or as characters representing the corresponding value in ASCII. The last argument must be a real number.
Random numbers are obtained through random(3). The name jot derives in part from iota, a function in APL.
EXAMPLES
The command
jot 21 -1 1.00
prints 21 evenly spaced numbers increasing from -1 to 1. The ASCII character set is generated with
jot -c 128 0
and the strings xaa through xaz with
jot -w xa%c 26 a
while 20 random 8-letter strings are produced with
jot -r -c 160 a z | rs -g 0 8
Infinitely many yes's may be obtained through
jot -b yes 0
and thirty ed(1) substitution commands applying to lines 2, 7, 12, etc. is the result of
jot -w %ds/old/new/ 30 2 - 5
The stuttering sequence 9, 9, 8, 8, 7, etc. can be produced by suitable choice of precision and step size, as in
jot 0 9 - -.5
and a file containing exactly 1024 bytes is created with
jot -b x 512 > block
Finally, to set tabs four spaces apart starting from column 10 and ending in column 132, use
expand -`jot -s, - 10 132 4`
and to print all lines 80 characters or longer,
grep `jot -s "" -b . 80`
SEE ALSO
ed(1), expand(1), rs(1), yes(1), printf(3), random(3), expand(1)
4th Berkeley Distribution June 6, 1993 JOT(1)