Why use different FS, the results is different?

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Why use different FS, the results is different?
# 1  
Old 09-21-2013
Bug Why use different FS, the results is different?

# echo '1 2 3 ' | awk -F' ' '{print NF}'
# echo '1:2:3:' | awk -F':' '{print NF}'

# 2  
Old 09-21-2013
When FS is set to a space character, leading and trailing spaces and tabs are removed from the input line and then any sequence of one or more space and tab characters act as field separators. When FS is another character (such as the colon in your 2nd example), every occurrence of the character acts as a field separator. And, since you have a trailing colon, there is an empty field after the last colon.
These 3 Users Gave Thanks to Don Cragun For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

I want to add a variable for the results from the formula of one variable and results of another var

Good morning all, This is the file name in question OD_Orders_2019-02-19.csv I am trying to create a bash script to read into files with yesterdays date on the file name while retaining the rest of the files name. I would like for $y to equal, the name of the file with a formula output with... (2 Replies)
Discussion started by: Ibrahim A
2 Replies

2. Shell Programming and Scripting

Df -h results in a loop

Hello everyone, I am doing a check of the disk space using df -h, I want to combine the result in break line; but the result after while/done is empty: # df -h Filesystem Size Used Avail Use% Mounted on rootfs 20G 14G 4.6G 75% / /dev/root 20G 14G 4.6G 75% /... (15 Replies)
Discussion started by: Abu Rayane
15 Replies

3. Shell Programming and Scripting

column the results

hello I'm writing a bash script and the thing is I want the results that come from the command call to be put the one under the other in ONE column.Instead they're put the one next to the other in different columns.the command is for loop do command | awk '{print $1,$2,$3} |... (1 Reply)
Discussion started by: vlm
1 Replies

4. Shell Programming and Scripting

how to print off results

print from an ip_list file containing 300 ip's the directory of the results is /var/tmp/ the will change according to the /tmp/ip_list file i.e I need the results from /var/tmp/ once done the script goes to the next ip address in... (11 Replies)
Discussion started by: slashbash
11 Replies

5. Shell Programming and Scripting

Can ctag and cscope support recording search results and displaying the history results ?

Hello , When using vim, can ctag and cscope support recording search results and displaying the history results ? Once I jump to one tag, I can use :tnext to jump to next tag, but how can I display the preview search result? (0 Replies)
Discussion started by: 915086731
0 Replies

6. Shell Programming and Scripting

Grep no results

Hello guys, I have been looking around but can't find the answer to my problem: If the grep command displays no results, print "no results have been found" and increment x. But if the grep command find something, do nothing. if echo "no results have been found $x" x=`expr $x + 1 `... (3 Replies)
Discussion started by: Benou
3 Replies

7. Shell Programming and Scripting

How do I transpose a of results ?

Hello, Can anyone advise me what command I could use to display the results of the following command ATOM 1 ca 2 o 3 h 4 h 5 o dE/dx 0.2057422D-01 0.2463722D-01-0.1068047D-01-0.1495280D-01-0.3725362D-02 dE/dy -0.7179106D-02-0.1554542D-01 0.1016889D-01 0.3268502D-02-0.4888578D-01 dE/dz... (3 Replies)
Discussion started by: wanchem
3 Replies

8. Solaris

truss results

moved to the Netwoking (0 Replies)
Discussion started by: gogogo
0 Replies

9. AIX

Strange ls results..

Multipart question.. Can anybody explain why this happens : -rw-rw-r-- 1 fnsw fnusr 1531061 Feb 13 21:45 filename1.log -rw-rw-r-- 1 fnsw fnusr 1760706 Feb 10 22:10 filename2.log -rw-rw-r-- 1 fnsw fnusr 1525805 Aug 16 2005 filename3.log -rw-rw-r-- 1... (3 Replies)
Discussion started by: dbridle
3 Replies

10. Programming

C program with two results.

I have this program that I execute into UNIX UX and after into UNIX AIX. The program are just below: #include <stdio.h> struct A { double d; char a; }; struct B { char a; double d; }; void main() { struct A Va; struct B Vb; (7 Replies)
Discussion started by: Gandalfcgb
7 Replies
Login or Register to Ask a Question