Sample Header Ad - 728x90

awk - print $0 ignores OFS

6 votes
3 answers
996 views
I want to output every Column / Field, but when I do it with the $0 variable, it ignores the default OFS variable which is a single space, so the :'s still get printed. Here is the command I tried:
cat /etc/passwd | awk -F':' '{print $0}'
Given this sample input:
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
I get this output from my command:
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
But I want my output to look like this:
root x 0 0 root /root /bin/bash
daemon x 1 1 daemon /usr/sbin /usr/sbin/nologin
--- Thanks for your help :)
Asked by Bog (1144 rep)
Aug 21, 2023, 02:09 PM
Last activity: Aug 12, 2025, 08:00 AM