Hi Gurus,
We have a ftpserver from which we do a dir command and output it to a local file.
The content of the ftpfile is:
I generally use awk '{print $4}' ftpfile. But, I realized that the filename in the ftp might contain spaces.
So I came up with the command:
But the above command prints new line for every print I give. I want it in the same line. I tried using cut but it doesn't help.
On an ad-hoc basis, I am currently using the below command:
awk '{if (NF!=4) {print $4,$NF}else {print $4}}' ftplist
The above command prints what I want but, I assume here that the filename will have only one space.
Please suggest.
Thanks that command helped. I have one more doubt. I am unable to use shell variables in awk. Could you help me again with that? I have a sample file like this:
Now I have a script where I allow the user to enter the name of project based on which I grep the file and give the path. But here too, I realized that I am doing grep on the entire file rather than on only first column. The problem for that is the user can give anything on the given line and it might result in undesirable output.
My desired output is if the user gives PCS, he should see /CLA/DATAFILES/FILES
I initially used :
grep "$a" filename|awk '{print $2}'
where a is the name of the project which user gives.
I tried to use:
awk '{if ($1=$a) {print $2}else{print "WRONG INPUT"}}' filename
But the above awk doesn't work. Please help
Thanks
Hi have a large spreadsheet which has 4 columns
APM00111803814 server_2 96085 Corp IT Desktop and Apps
APM00111803814 server_2 96085 Corp IT Desktop and Apps
APM00111803814 server_2 96034 Storage Mgmt Team
APM00111803814 server_2 96152 GWP... (6 Replies)
Hi Experts,
I am new to UNIX. One of my file records are like below
220 IN C/A 515013 NULL NULL
220 IN C/A 515017 NULL NULL
225 IN C/A 333701 NULL NULL
225 IN C/A 515034 NULL NULL
225 IN C/A 499201 NULL NULL
225 IN C/A 499202 NULL NULL
The above mentioned records delimiter is... (4 Replies)
I have a file as follows
ATOM 5181 N AMET K 406 12.440 6.552 25.691 0.50 7.37 N
ATOM 5182 CA AMET K 406 13.685 5.798 25.578 0.50 5.87 C
ATOM 5183 C AMET K 406 14.045 5.179 26.909 0.50 5.07 C
ATOM 5184 O MET K... (14 Replies)
Hi friends,
My input file is this way
chr1 100 200 "abc"
chr1 350 400 "abc"
chr2 450 600 "def"
chr2 612 780 "def"
How do I make this file into
chr1 100 400 "abc"
chr2 450 780 "def"
This is basically matching on the fourth column and taking the minimum of second column and the... (4 Replies)
BAQ001 /dev/rdsk/c2t0d7 1C13 (M) RW 69053
The line above is from a text file. I want to use awk to extract the value in the third column 1C13.
I just can't seem to get the syntax right or something. Any help would be appreciated.
Thanks, (5 Replies)
Hi All,
If anybody could help me with my scenario here. I have a statement file. Example of some content:
DATE DESC Debit Credit Total Rate
02-Jan-08 Lodgement 200.00 1200.00 2.51
14-Sep-07 Withdrawal 50.00 1000.00 ... (8 Replies)
How to manipulate first column and reverse the line order in third and fourth column as follws?
For example i have a original file like this:
file1
0.00000000E+000 -1.17555359E-001 0.00000000E+000
2.00000000E-002 -1.17555359E-001 0.00000000E+000
... (1 Reply)
hi i have a file with content, i need to extract last column from each line including spaces and form a string
i used echo "$LINE" | awk '{print $1,$2}' | grep '^\ 33333030 30303030 30303030 CTL1330000000000
44453932 33353237 36333030 0000DE9235276300
30305453 30353934 44453932... (4 Replies)
Hi,
I am currently confused.
Suppose I have a file something like the one below.
4299|raj Telecommunications|12|||||
4302|anjali International Ltd.|86|ritchie||dong|(000)2890 9993 |(222)4881 3689
4305|フィデュシアリ・ト-スト・インター...ショ...ル投資顧問株式会社 |112||||01-9211-1931 |08-3677-1985
Now... (2 Replies)