You are not logged in.
I got an output from a command that outputs a long line that I'd like to indent and chop off at the 76 character. Currently the command outputs:
thes archla
! archla is not in the dictionary. Possible alternatives:
arch la, arch-la, archly, Ashla, Arch, arch, ashlar, Arch's, Archean, arch's, arches, archway, Archy, Ashli, Ashly, Archer, Archie, Rachel, archer, Ariela, arched, archival, Aral, racial, Rachele, Ala, Archy's, Ashil, archaic, areal, Ashlan, Marchall, Marshal, marshal, Aila, Alla, Arly, Chlo, ache, achy, Ashla's
I suppose I might be able to find a way for sed to do this but was thinking there might be a tool that already does this. Any ideas?
Last edited by Gen2ly (2009-11-12 04:36:27)
Setting Up a Scripting Environment | Proud donor to wikipedia - link
Offline
man fmt
Offline
lol, commands you never hear of. Seems like I learn a new linux command that been there all along every day. Thanks.
Setting Up a Scripting Environment | Proud donor to wikipedia - link
Offline
much easier that that
pipe it through " | cut -c 1-72"
Offline
hmmmmmm unless you want it to wrap..... in which case, cut won't work
Offline
never heard of fmt either, but i think sed can do everything it's capable of... say, does this do what you want?
sed 's/.\{76\}/&\n\t/g'
This silver ladybug at line 28...
Offline
Edit2:
Ahh, I see now. You want to cut it off, not wrap it. Ignore this post then.
Maybe I'm misunderstood the question, but I'm surprised no one's mentioned fold.
fold -sw 76
should do it. It won't break up words or anything, and it's included in the base Arch install as far as I remember.
Edit:
Here's an example from my .bashrc showing something similar to what you seem to be doing,
function etym(){
for term in "$@"
do
url="http://www.etymonline.com/index.php?term=$term"
curl -s $url | grep "<dd " | sed 's/<[^>]*>//g' | fold -sw 79
echo
done
}
Last edited by AlecSchueler (2009-11-16 14:45:05)
Offline