Reputation: 23
I execute the command ifconfig eth1 on the terminal on a linux machine, and want the output on the same line.
Eg:Observed:
[root@host ~]# ifconfig eth1
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1400
What I want is:
[root@host ~]# ifconfig eth1 eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1400
i.e I want to remove the initial newline from the output.
Upvotes: 1
Views: 1065
Reputation: 27516
You can try with:
printf '\033[A\033[29C'; ifconfig eth0
But you would need to replace the 29
with the position where you want the output to be printed (\033[A
moves the cursor up one line, \033[50C
moves the cursor to the right 29
times.
Upvotes: 1
Reputation: 3566
You could execute like this:
$ echo $(ifconfig eth0)
where the initial $ is ment to be your shell's prompt. For some reason this way all the newlines are removed and the output of "ifconfig eth0" (which is executed in a subshell) is printed on one line.
Upvotes: 1