if i understand properly, u want the leading spaces of first column removed
try this
awk '{printf("%-12s %12s %22s\n",$1,$2,$3) ' filename > outfile
after u see the results u may modify the line accordingly
i have given a space between columns;
Hi again,
Well, I'm sorry to say it, but that doesn't give the expected output, at least not on my machine. The columns don't line up. And he also wanted headers, which was the reason for either two printf statements in an awk program or other AWKward cats and whiles and echoes... a seemingly complicaticated way to do it.
If it wasn't for the headers, Danmeros original solution would still have been the most correct:
or even
I did an experiment: the latter is faster on my machine on small files (the actual content supplied by OP) but when the file is 100 times bigger the awk program is a lot faster, a 10th of the time. So the conclusion is that if You need a reason to go for a cup of cocoa, run the while loop. If You are anxious to get home at the end of the day, do the awk. It's several nanoseconds we're dealing with here dudes!
The point, in this case, is taking in the arguments with any program that ignores repeated whitespace and reformat it in the desired fashion. At least that's how I see it. And which I missed completely in my first attempts at cracking it, focusing on how to handle or convert whitespace.
Hi Everyone,
I have a very simple problem and i am stuck in that from last 8 days. I tried many attempts, googled my query but all in vain.
I have a text file named "test.txt"
In that suppose i have contents like:
Java:
1 Object oriented programming language
2 Concepts of Abstraction... (5 Replies)
There is a text file in my project named as "mom.txt" in which i want to have contents like..................
LSCRM(Application Name):
1: This is my first application.
2: Today we did shell scripting automation for this app.
3: It was really a good fun in doing so.
4: Really good.| (Here i... (7 Replies)
Hi Friend ,
i have one file say xyz.lst and it has content like
dn: cn=m.hariharan,cn=employee,cn=delhi circle,cn=users,dc=industowers,dc=c
dn: cn=ajay.jain,cn=employee,cn=gujarat circle,cn=users,dc=industowers,dc=com
dn: cn=ajitkumar.thakor,cn=employee,cn=gujarat... (4 Replies)
Hi!
I get a md5 hash of a file with this command:
openssl md5 /Users/me/MyLogo.png | cut -f 2 -d ' '
"cut" because I just want the hash. But there is a problem -> that doen't work with a path with spaces:
openssl md5 /Users/me/MyLogo 2.png | cut -f 2 -d ' '
The result is "2.png)=" ...... (1 Reply)
Hi
I have a strange problem when using cut command
when i am using the below command, it is working fine,I am getting the data in new file xyz.dat
cut -c 1-75 abc.dat > xyz.dat
when i am using the below command, I am getting the data in new file abc.dat , but empty file
cut -c 1-75... (4 Replies)
I'm new to shell programming, and am having a problem in a (Korn) shell program, which boils down to this:
The program reads a record from an input file and then uses a series of
"cut" commands to break the record into parts and assign the parts to
variables. There are no delimiters in the... (2 Replies)
I am trying to take one part of my text from file and save it to variable $x
I tryed this...
x=`cut -c 6-9 $fajl`
my file looks like this
fajl:
21890001277 89386911 23638FBCDC 28EE01A1 0000 26855 124 244326
21890001277 89766911 23638FBCDC 28E021A1 0000 26557 134 684326
21890001277... (7 Replies)
hi ,
i used ls -ltr | cut -f 1 > \dev\tty
but all teh coulmns r getting printed instead of only one........how can i resolve this?
prob 2 :
wud be able start cutting from last field......supposing in the case of dyanmic list.i dunno the field number of last column.......so is... (3 Replies)
#!/usr/bin/bash
cat /etc/passwd | while read A
do
USER=`echo “$A” | cut -f 1 -d “:”`
echo “Found $USER”
done
This shell script should make USER = the first field of the first line of the file /etc/passwd
Eg:
adm
daemon
bob
jane
kev
etc ...
However USER=echo... (3 Replies)
Hi all!
Here is my problem :
$ more file
yougli:passwd:123456:3265:Yepa Yepo:/home/yougli:/bin/ksh
As you can see, in the field "information", there are two spaces between "Yepa" and "yepo".
My problem is :
$ PARAM='more file | cut -d":" -f5'
$ echo $PARAM
Yepa Yepo
Now i only... (2 Replies)