Required unix command!!!


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
# 1  
Required unix command!!!

Hi,

In a file I have data like...

-rw-r----- 1 ftpuser users 1036695 Jul 6 14:59 ./APRIL 2007/Ujjain/My Disc (D)/9565DW07.04B
-rw-r----- 1 ftpuser users 124080 Jul 6 14:59 ./APRIL 2007/Vadodara/vad_APRIL07/2082DW07.04B

The above data is extracted using "find . -name 4704DW07.03B -print > file1"

I want to generate output from the file like
1036695,9565DW07.04B
124080,2082DW07.04B

can anybody give me a command to do the same(without shell scripts).

Thanking you in advance,
Ronald.
# 2  
Code:
awk '{print $5","basename ($9)}' datafile

# 3  
Hi,

I'm getting following result

#cat file1 | awk '{print $5","basename($9)}'
awk: Function basename is not defined.
The input line number is 1.
The source line number is 1.


Regards,
Ronald.
# 4  
Hi,

Also please note I have files like
-rw-r----- 1 ftpuser users 348738 Jul 6 14:38 ./APRIL 2007/patna/4976DW07.04B

i.e. between APRIL 2007, there is a space.

Regards,
Ronald.
# 5  
Quote:
Originally Posted by ronald_brayan
Hi,

Also please note I have files like
-rw-r----- 1 ftpuser users 348738 Jul 6 14:38 ./APRIL 2007/patna/4976DW07.04B

i.e. between APRIL 2007, there is a space.

Regards,
Ronald.
Code:
$ cat file
-rw-r----- 1 ftpuser users 1036695 Jul 6 14:59 ./APRIL 2007/Ujjain/My Disc (D)/9565DW07.04B
-rw-r----- 1 ftpuser users 124080 Jul 6 14:59 ./APRIL 2007
$ awk -F"[ /]" ' { print $5 "," $NF } ' file
1036695,9565DW07.04B
124080,2082DW07.04B

# 6  
Hi,

Thanks for your response. In some cases it works.

In the following case
[devofsa]:/db01/BOIDW_FEED_DIR/BOIDW_FTP_DIR/cibex#cat file2
-rw-r----- 1 ftpuser users 249384 Jul 6 14:38 ./APRIL 2007/patna/4975DW07.04B
-rw-r----- 1 ftpuser users 348738 Jul 6 14:38 ./APRIL 2007/patna/4976DW07.04B

[devofsa]:/db01/BOIDW_FEED_DIR/BOIDW_FTP_DIR/cibex#cat file2 | awk -F"[ /]" ' { print $5 "," $NF } '
ftpuser,4975DW07.04B
ftpuser,4976DW07.04B

Is there something wrong. in this case instead of user I want size!

Ronald.
# 7  
Quote:
Originally Posted by ronald_brayan
Hi,

Thanks for your response. In some cases it works.

In the following case
[devofsa]:/db01/BOIDW_FEED_DIR/BOIDW_FTP_DIR/cibex#cat file2
-rw-r----- 1 ftpuser users 249384 Jul 6 14:38 ./APRIL 2007/patna/4975DW07.04B
-rw-r----- 1 ftpuser users 348738 Jul 6 14:38 ./APRIL 2007/patna/4976DW07.04B

[devofsa]:/db01/BOIDW_FEED_DIR/BOIDW_FTP_DIR/cibex#cat file2 | awk -F"[ /]" ' { print $5 "," $NF } '
ftpuser,4975DW07.04B
ftpuser,4976DW07.04B

Is there something wrong. in this case instead of user I want size!

Ronald.
I dont find any wrong here. Check whether that line contain non-printable characters
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #180
Difficulty: Medium
The Apple II was invented by Steve Jobs.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to search a text in file and retrieve required lines following it with UNIX command?

I have requirement to search for a text in the file and retrieve required lines that is user defined with unix command. Eg: Find the text UNIX in the below file and need to return Test 8 & Test 9 Test 1 Test 2 Test 3 Test 4 UNIX Test 5 Test 6 Test 7 Test 8 Test 9 Result can... (8 Replies)
Discussion started by: Arunkumarsak4
8 Replies

2. Shell Programming and Scripting

Required Command in awk command

Hi Firends, I wanted to extract the first record of the file which starst with character say "X". And I tried an awk command which works when i try to execute it individually: awk 'substr($1,1,1)=="X"' inputfile.txt But when I use the same command in my script for which I am passing the... (2 Replies)
Discussion started by: Ajay Venkatesan
2 Replies

3. Shell Programming and Scripting

Getting required fields from a test file in required fromat in unix

My data is something like shown below. date1 date2 aaa bbbb ccccc date3 date4 dddd eeeeeee ffffffffff ggggg hh I want the output like this date1date2 aaa eeeeee I serached in the forum but didn't find the exact matching solution. Please help. (7 Replies)
Discussion started by: rdhanek
7 Replies

4. Cybersecurity

Help Required: Command to find IP address and command executed of a user

Hi, I am trying to write a script which would figure out who has run which command and their IP. As i dont have any clue as to which commands would do this job, i request some gurus to help me on this. Thanks Vishwas (2 Replies)
Discussion started by: loggedout
2 Replies

5. Shell Programming and Scripting

Help Required regarding wc command

Hi guys, I want to find the number of records in a particular file and store that value in any other variable. I am trying this below command but it is not working and giving me an error "Uninary Operator Expected". say I have taken a variable name 'count' in which I have to store the no. of... (7 Replies)
Discussion started by: dtidke
7 Replies

6. UNIX for Advanced & Expert Users

help required in unix command/script

Hi All, Please help me in writting the script File contains: ========= 11424444, <basicpage> jfalfksf <dateofbirth>10/02/2005</dateofbrith> jkaklgja lg'd .... 11423224444, <basicpage> jfalfksf <dateofbirth>11/02/2005</dateofbrith> jkaklgja lg'd 11433523224444, <basicpage>... (1 Reply)
Discussion started by: thaduka
1 Replies

7. UNIX for Dummies Questions & Answers

Unix command help required

Hi All, Can anyone please help me in sort out the command to get the following command say File abc.log contains .... ...... This is the first line This is the second line This is the third line This is the fourth line This is the fifth line This is the first line This is the... (7 Replies)
Discussion started by: thaduka
7 Replies

8. UNIX for Dummies Questions & Answers

Help Required in Unix Command

Hi All, Can anyone please help me in unix command Query: ==== File contains data along with date and time stamp like, .. Date: 08:23:2005 01:00:00 method: xyz init variables Date 08:23:2005 01:00:01 method: xyz finished init variable .... (2 Replies)
Discussion started by: thaduka
2 Replies

9. Solaris

unix command required.

I need to get a few details from the command line. I need to get the kilobytes per second that my server is transfering to another or has available and I need to test the connection to make sure that its a sound connection. I also need to keep track of the response time. I have been playing... (1 Reply)
Discussion started by: nowayin
1 Replies

10. UNIX for Dummies Questions & Answers

UNIX PATH info required PLEASE HELP (I'm new to unix)

I need to know how to enter a unix path in a cgi script for a guest book: example: My URL is http://www.kitachi.info I have an html file in the main folder on my site, the file is called : gbook.html what would the correct unix path for this file be ??? the part of the script... (1 Reply)
Discussion started by: akitachi
1 Replies

Featured Tech Videos