unix help plz - Sajha Mobile
SAJHA MOBILE
unix help plz
Posts 7 · Viewed 5241 · Go to Last Post
phone_book
· Snapshot
Like · Likedby · 0

 


#! /bin/sed -nf
H
$ {
x
s/\n//g
p
}


i found the above sed command means remove all newline characters. but can anyone plz explain me how does this command work?...thank u  

M$Hacks
· Snapshot
Like · Liked by · 0
#!/bin/sed -nf
H #defining a pattern space to hold something
$ { #go through all the lines in file, try putting values 4..it will parse through 4 lines only etc
x #swap pattern and hold space
s/\n//g #search new line character and replace with nothing, ie remove new line character
p #print pattern space
}

Hope it helps.
K6
· Snapshot
Like · Liked by · 0
Not sure if this is helpful but 's/\n//g' ko 's' bhanya search for ho, ani the next '/' bhanya next command ho, '/n' represents the newline character. '//' bhanya replace with nothing ho ani 'g' bhanya global. so it means search for \n ani replace with nothing, through the text body.

For example you might have:

The quick brown fox jumps over the lazt dogs.
The quick brown fox jumps over the lazt dogs.
The quick brown fox jumps over the lazt dogs.The quick brown fox jumps over the lazt dogs.
The quick brown fox jumps over the lazt dogs.
The quick brown fox jumps over the lazt dogs.


now if u wanna change 'lazt' into 'lazy' for the whole body of text, just do ' s/lazt/lazy/g' and ure good :)

peace.

phone_book
· Snapshot
Like · Liked by · 0

thank you both for quick response. thats what exactly what i was looking for


thank you again

PeaceSoul
· Snapshot
Like · Liked by · 0
Looks pretty good explanation. What book do you guys recommend for new scripter!!!
M$Hacks
· Snapshot
Like · Liked by · 0
peacesoul, i RTFM most of the time and search google for more tips. Hope that helps..
mrbikash
· Snapshot
Like · Liked by · 0





 

#!/bin/sed -nf
H #defining a pattern space to hold something
$ { #go through all the lines in file, try putting values 4..it will parse through 4 lines only etc
x #swap pattern and hold space
s/\n//g #search new line character and replace with nothing, ie remove new line character
p #print pattern space
}
hope this works brother

what u do n where u works

i mdoing kick start help me bikashbha@yahoo.com
Please log in to reply to this post

You can also log in using your Facebook
View in Desktop
What people are reading
You might like these other discussions...
· Posts 8 · Viewed 389
· Posts 1 · Viewed 76
· Posts 1 · Viewed 83
· Posts 3 · Viewed 553 · Likes 2
· Posts 1 · Viewed 106
· Posts 1 · Viewed 132
· Posts 1 · Viewed 139
· Posts 1 · Viewed 147
· Posts 1 · Viewed 141
· Posts 8 · Viewed 819



Your Banner Here
Travel Partners
Travel House Nepal