Author Topic: Formatting terminal command output  (Read 675 times)

0 Members and 1 Guest are viewing this topic.

Offline Keith

  • Sr. Member
  • ****
  • Posts: 456
  • Karma: 10
  • Gender: Male
  • Linux Novice
    • View Profile
    • Awards
Formatting terminal command output
« on: February 12, 2013, 01:35:47 pm »
The terminal command date; iwlist wlan0 scan |grep -i quality outputs the current date/time and data about my wireless connection on two lines:

keith@desktop-1:~$ date; iwlist wlan0 scan |grep -i quality
Tue Feb 12 13:27:37 GMT 2013
                    Quality=54/70  Signal level=-56 dBm

Is it possible output both the date and data on one line? 


Offline Mark Greaves (PCNetSpec)

  • Administrator
  • Hero Member
  • *****
  • Posts: 13588
  • Karma: 339
  • Gender: Male
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
    • Awards
Re: Formatting terminal command output
« Reply #1 on: February 12, 2013, 03:15:49 pm »
How about:
Code: [Select]
echo $(date)$(iwlist wlan0 scan | grep -i quality)
?
WARNING: You are logged into reality as 'root'

logging in as 'insane' is the only safe option.

Offline Keith

  • Sr. Member
  • ****
  • Posts: 456
  • Karma: 10
  • Gender: Male
  • Linux Novice
    • View Profile
    • Awards
Re: Formatting terminal command output
« Reply #2 on: February 12, 2013, 03:36:26 pm »
You're a star!  What's it like to know what you're doing?!
I might have another one in a short while!

Offline Mad Penguin

  • #Mad_Penguin_UK
  • Administrator
  • Hero Member
  • *****
  • Posts: 1318
  • Karma: 10017
  • Gender: Male
    • View Profile
    • Linux in the UK
    • Awards
Re: Formatting terminal command output
« Reply #3 on: February 12, 2013, 03:36:50 pm »
Code: [Select]
#!/bin/bash
for i in `iwlist wlan0 scan|grep -i quality`
do
  echo -n "$i "
done
echo ""

Offline Keith

  • Sr. Member
  • ****
  • Posts: 456
  • Karma: 10
  • Gender: Male
  • Linux Novice
    • View Profile
    • Awards
Re: Formatting terminal command output
« Reply #4 on: February 12, 2013, 04:15:55 pm »
Yep: that works, too.  Not such a Mad Penguin, then! 
Many thanks, gents.

Offline Mark Greaves (PCNetSpec)

  • Administrator
  • Hero Member
  • *****
  • Posts: 13588
  • Karma: 339
  • Gender: Male
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
    • Awards
Re: Formatting terminal command output
« Reply #5 on: February 12, 2013, 05:08:54 pm »
Scatty Spheniscidae ;D
WARNING: You are logged into reality as 'root'

logging in as 'insane' is the only safe option.

Offline Keith

  • Sr. Member
  • ****
  • Posts: 456
  • Karma: 10
  • Gender: Male
  • Linux Novice
    • View Profile
    • Awards
Re: Formatting terminal command output
« Reply #6 on: February 12, 2013, 05:29:02 pm »
But not, I trust, Spheniscus  ;)

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal