Removing spaces from the output of a head command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Removing spaces from the output of a head command
# 1  
Old 12-10-2008
Removing spaces from the output of a head command

Im running the below commands in a script.

Total_confirms=`cat $OUTPATH/count_po* | head -4 | tail -1`
#
echo "Total Confirms records we need: $Total_confirms" >> $LOG2

The problem is its always returning 4 spaces before the result.. Can I pipe the result into something else to remove the spaces.. was looking at the cut command but don't think it applies here.

I'm just trying to align the output so it's not all over the place..

Last edited by Jazmania; 12-10-2008 at 12:11 PM..
# 2  
Old 12-10-2008
Hammer & Screwdriver cut command

to skip over the first four places
Code:
cut -c5-

should do the trick
# 3  
Old 12-10-2008
Thanks, works nicely..

Didn't know cut would do that..
# 4  
Old 12-10-2008
Just another question regarding the cut command... have been messing around with it but cant get it working properly.. how do you type the cut command to just return the time 07:37:43 from the below line?

job_1 12/10/2008 07:37:43 12/10/2008 11:22:10 SU 23464234/1
# 5  
Old 12-10-2008
Hammer & Screwdriver Assuming that is a space character between fields

Code:
> echo job_1 12/10/2008 07:37:43 12/10/2008 11:22:10 SU 23464234/1 | cut -d" " -f3
07:37:43

or
[since awk assumes space or tab as delimiter]

Code:
> echo job_1 12/10/2008 07:37:43 12/10/2008 11:22:10 SU 23464234/1 | awk '{print $3}'
07:37:43

# 6  
Old 12-10-2008
Thanks again... I'll stick with the cut... Its easier..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Removing spaces in the second field alone

Consider my input string as "abc|b f g|bj gy" I am expecting the output as "abc|bfg|bj gy". Please let me know how to achieve this in unix? Thanks (8 Replies)
Discussion started by: pandeesh
8 Replies

2. Shell Programming and Scripting

Removing spaces from record

HI i have record as shown below 402665,4X75,754X_FERNIE BC,12F2,008708,FERNIE BC,1,UTC ,UTC ,250 402665,4X75,754X_FERNIE BC,F212,008708,FERNIE BC,1,UTC ,UTC ,250 402665,4Y75,754Y_FERNIE BC,22F2,008708,FERNIE BC,1,UTC ,UTC ,250 here i want to remove multiple spaces into no... (3 Replies)
Discussion started by: raghavendra.cse
3 Replies

3. Shell Programming and Scripting

Removing spaces in a line

Hi All, I have a line like this " field1;field2;field3 " (single space after and before double quotes). Now i have to remove these single space . Kindly help me. Thanks in advance (2 Replies)
Discussion started by: krishna_gnv
2 Replies

4. Shell Programming and Scripting

Removing blank spaces, tab spaces from file

Hello All, I am trying to remove all tabspaces and all blankspaces from my file using sed & awk, but not getting proper code. Please help me out. My file is like this (<b> means one blank space, <t> means one tab space)- $ cat file NARESH<b><b><b>KUMAR<t><t>PRADHAN... (3 Replies)
Discussion started by: NARESH1302
3 Replies

5. UNIX for Dummies Questions & Answers

Removing spaces...

Hey, I'm using the command from this thread https://www.unix.com/unix-dummies-questions-answers/590-converting-list-into-line.html to convert vertical lines to horzontal lines. But I need to remove the spaces that is created. Unfortunately I can't figure out where the space is in the code.. I... (2 Replies)
Discussion started by: lost
2 Replies

6. UNIX for Dummies Questions & Answers

Removing Double Spaces for cut command

Hi I have a shell script that looks for running processes in order to kill them. The script (ksh) gets the PID of these processes using the following: PROCS=`ps -fu ${USERID} | egrep "MONITOR" | grep -v grep | cut -d" " -f4` However, I spotted an issue where PID's of different lengths... (3 Replies)
Discussion started by: mikem22
3 Replies

7. Shell Programming and Scripting

removing spaces

hey.. i had a problem with the unix command when i want to remove the white spaces in a string..i guess i cud do it with a sed command but i get an error when i give space in the square brackets.. string="nh hjh llk" p=`echo $string | sed 's/ //g'` i donno how to give space charater and... (2 Replies)
Discussion started by: sahithi_khushi
2 Replies

8. Shell Programming and Scripting

removing spaces after sperator

Hi friends i have problem 6000000001| CDC049| 109| CDC| 02/02/2006| Auto| New Add| 02/03/2006 6000000002| CDC033| 109| CDC| 02/02/2006| Auto| New Add| 02/03/2006 6000000003| CDC037| 109| CDC| 02/02/2006| Auto| New Add| 02/03/2006 6000000004| CDC031| ... (6 Replies)
Discussion started by: vishnu_vaka
6 Replies

9. UNIX for Dummies Questions & Answers

Removing spaces between records

Hi I have an XML file. Which has spaces between different records.... current file( Has many lines, like this... I want to delete all the spaces between > and <, if there are only spaces between them) input file <xyzr> <abc>1234</xyzr> <aaa> <bbb> ayz mnz</bbb> <sen>KEA... (6 Replies)
Discussion started by: thanuman
6 Replies
Login or Register to Ask a Question