Sponsored Content
Top Forums Shell Programming and Scripting copying file information using awk & grep Post 302562944 by nrjrasaxena on Sunday 9th of October 2011 04:29:02 AM
Old 10-09-2011
Hi,

The files kept in the "/castor/cern.ch/user/s/sudha/forPooja" has field :
Code:
[lxplus415] /afs/cern.ch/user/p/pooja/test > rfdir /castor/cern.ch/user/s/sudha/forPooja
-rw-r--r--   1 cms003   zh                  969064642 Jul 29 17:08 data_10_0_dBw.root
-rw-r--r--   1 cms003   zh                 1021157382 Jul 29 18:46 data_11_0_rRG.root
-rw-r--r--   1 cms003   zh                 1136693129 Jul 30 09:33 data_13_0_Ljr.root
-rw-r--r--   1 cms003   zh                 1136693192 Jul 30 12:50 data_13_2_VEo.root
-rw-r--r--   1 cms003   zh                  458432186 Jul 30 04:58 data_14_0_5TU.root
-rw-r--r--   1 cms003   zh                   75970008 Jul 29 14:17 data_15_0_WKR.root
-rw-r--r--   1 cms003   zh                 1279818743 Jul 30 14:04 data_16_1_Ohw.root
-rw-r--r--   1 cms003   zh                  573268613 Jul 29 16:11 data_18_0_znC.root
-rw-r--r--   1 cms003   zh                  692655767 Jul 29 22:17 data_19_0_KMo.root

I want the information written in FILE.txt is like:
Code:
rfio:///castor/cern.ch/user/s/sudha/forPooja/data_10_0_dBw.root
rfio:///castor/cern.ch/user/s/sudha/forPooja/data_19_0_KMo.root

In awk comand
Code:
awk '{print "$2"$9}' > $2

$9 is the column for data**.root information and same for $2.

Yes you are right with this statement.
"Do you want to print the filenames having the string "data" in the filename with rfio:///castor/cern.ch/user/s/sudha/forPooja/ as prefix into FILE.txt?"

hope it is clear now.
Many thanks for reply..
pooja
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Copying file names returned from a grep command into another directory

When I do the following : grep -l "string" *, I get a list of file names returned. Is there a way to copy the files returned from the list into another directory ?. Thanks. (4 Replies)
Discussion started by: Kartheg
4 Replies

2. Shell Programming and Scripting

grep & awk

Hi all, I'm figuring on how to grep only specific data I want below: Bin Total % ----- ------- ----- 1 15 42.9 Bin Total % ----- ------- ----- 2 15 ... (3 Replies)
Discussion started by: *Jess*
3 Replies

3. Shell Programming and Scripting

awk (gawk) grep & columns

Hi, I'm working with gawk (on DOS) today. A goal is: find a string for-instance '123', cut a line in two columns and write second one. The problem is: command line works OK, awk file doesn't. But I would like to work with file because there are many strings to find. input: line command: awk... (4 Replies)
Discussion started by: frajer
4 Replies

4. Shell Programming and Scripting

Copying Information from One File to Another File in Shell

Hello, I'm new to scripting and I need help moving text from one file to another file. Here are examples what the files look like. File 1: Ac-223 2.10m A 1 0 0 0 Fr-219 358 9.9000E-01 0 0.0 0 0.0 0 0.0... (1 Reply)
Discussion started by: tamachan414
1 Replies

5. Shell Programming and Scripting

Grep'ing information from a log file on SUN OS 5

Hi Guys, I'm trying to write an script that will be launched by a user. The script will look at a log file and check for alerts with the date (supplied by user) and a machine's hostname (also supplied by the user). I'm trying to get the output formatted just like the log file. The logfile looks... (5 Replies)
Discussion started by: illgetit
5 Replies

6. Shell Programming and Scripting

Copying the Header & footer Information to the Outfile.

Hi I am writing a perl script which checks for the specific column values from a file and writes to the OUT file. So the feed file has a header information and footer information. I header information isaround107 lines i.e. Starts with START-OF-FILE ....... so on .... ... (11 Replies)
Discussion started by: filter
11 Replies

7. UNIX for Dummies Questions & Answers

Grep? - using a file of terms to search another file when the information is on a different line

I have a flat file that looks like this, let's call it Chromosome_9.txt: FT /Gene_Name="Guanyl-Acetylase 9" FT /Gene_Number"36952" FT /Gene_Name="Endoplasmic Luciferase" FT /Gene_Number"36953" FT ... (4 Replies)
Discussion started by: Twinklefingers
4 Replies

8. Shell Programming and Scripting

Include information in certain columns using grep and awk

HI all, I have data in a file that looks like this: 1 HOW _ NNP NNP _ 3 nn _ _ 2 DRUGS _ NNP NNP _ 3 nn _ _ 3 ACT _ NNP NNP _ 0 null _ _ 4 : _ ... (3 Replies)
Discussion started by: owwow14
3 Replies

9. Shell Programming and Scripting

sed / awk / grep to extract information from log

Hi all, I have a query that runs that outputs data in the following format - 01/09/12 11:43:40,ADMIN,4,77,Application Group Load: Name(TESTED) LoadId(5137-1-0-1XX-15343-15343) File(/dir/dir/File.T03.CI2.RYR.2012009.11433350806.ARD) InputSize(5344) OutputSize(1359) Rows(2) Time(1.9960)... (8 Replies)
Discussion started by: jeffs42885
8 Replies
GREP(1) 						      General Commands Manual							   GREP(1)

NAME
grep - search a file for a pattern SYNOPSIS
grep [ option ... ] pattern [ file ... ] DESCRIPTION
Grep searches the input files (standard input default) for lines (with newlines excluded) that match the pattern, a regular expression as defined in regexp(6). Normally, each line matching the pattern is `selected', and each selected line is copied to the standard output. The options are -c Print only a count of matching lines. -h Do not print file name tags (headers) with output lines. -i Ignore alphabetic case distinctions. The implementation folds into lower case all letters in the pattern and input before interpre- tation. Matched lines are printed in their original form. -l (ell) Print the names of files with selected lines; don't print the lines. -L Print the names of files with no selected lines; the converse of -l. -n Mark each printed line with its line number counted in its file. -s Produce no output, but return status. -v Reverse: print lines that do not match the pattern. Output lines are tagged by file name when there is more than one input file. (To force this tagging, include /dev/null as a file name argument.) Care should be taken when using the shell metacharacters $*[^|()= and newline in pattern; it is safest to enclose the entire expression in single quotes '...'. SOURCE
/sys/src/cmd/grep.c SEE ALSO
ed(1), awk(1), sed(1), sam(1), regexp(6) DIAGNOSTICS
Exit status is null if any lines are selected, or non-null when no lines are selected or an error occurs. GREP(1)
All times are GMT -4. The time now is 05:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy