sed command

I have a text file as follows:

foo
bar
foobar

How can I delete all leading and/or trailing blank spaces, tab from each line using sed command?

{ 5 comments }

I have installed Debian or Ubuntu Linux on Dell Inspiron / Latitude / Precision / Vostro laptop. How do I see the current CPU temperature? How do I control and see fan status on Dell laptop?

{ 26 comments }

I am a new Linux user. I have text files with lots of empty lines. How do I delete all empty lines under Linux or Unix operating systems?

{ 3 comments }

I have a directory with many files. I am trying to write a shell script that will only show first 10 or 20 lines of a file. How do I display first 10 or 20 lines of a file on Linux or Unix-like systems?

{ 0 comments }

How do I display first line of a text file called foo.txt on Linux or Unix-like operating systems?

{ 0 comments }

I have a bash variable as follows:

output="$(awk -F',' '/Name/ {print $9}' input.file)"

How do trim leading and trailing whitespace from bash variable called $output? How do I trim trailing whitespace from $output?

{ 10 comments }

I have a line as follows in squid.conf file. My sever is hosted in a cloud:

acl verizonfios src 1.2.3.4

My ISP will force an IP address change every week or two. I would like to replace them with a new IP

acl verizonfios src 4.5.6.7

How do I replace the line starting with “acl verizonfios” with new IP address using sed and ssh?

{ 1 comment }