spacing
hello i want to display
THIS Hostname : dell Ip address : 192.168.1.103 CPU Name : Intel(R) Xeon(TM) CPU 2.40GHz TO Hostname <space> : dell Ip address <space> : 192.168.1.103 CPU Name <space> :Intel(R) Xeon(TM) CPU 2.40GHz made the : to one line using bash please help me |
Quote:
What do you mean by this? Have a look at the man page for sed: Code:
man sed Kind regards, Eric |
You probably want to line up the second column straight, right?
Try sed s/':'/':\t'/g '\t' will insert tabulation (equal to several spaces). So, for example, if you have a file "input" with the text you want to transform, you do something like this: Code:
cat input | sed s/':'/':\t\t'/g > output |
Quote:
|
Quote:
Code:
sed 's/:/:\t\t/' input |
Quote:
|
Quote:
|
Quote:
im using "\ \ " to space.. but if you have other command tell me |
example i use this command for spacing
OS=`cat /etc/*release` echo "OS Used" \ \ \ \ \ \ \ \ \ \ \ \ \ " : $OS" but the command doesnt look nice if i use this. so how to change the \ \ to other command using your cat input | sed s/':'/':\t\t'/g > output |
Hi, Athrin -
As an example, this command adds six spaces: Code:
OS=`cat /etc/*release` |
Quote:
Code:
OS=`cat /etc/*release` |
Quote:
Anyway, athrin, I don't understand why you insist on using spaces instead of tabs, because tabs (as far as I know) have a nice property of lining things straight, so it doesn't matter if the text before the tabs is a bit shorter or longer. echo -e "OS Used"\t\t":$OS" looks simpler to me (-e option enables interpretation of backslash escape sequences). |
Quote:
|
All times are GMT -5. The time now is 07:30 AM. |