01-05-2011
Advanced grep'in... grep for data next to static element.
I have a directory I need to grep which consists of numbered sub directories. The sub directory names change daily. A file resides in this main directory that shows which sub directories are FULL backups or INCREMENTAL backups.
My goal is to grep the directory for the word "full" and then preceding that word in the file is the name of the sub directory the FULL backup is in. So I then need to grab that name and execute a tar or cp command on that directory.
EXAMPLE: contents of the directory are: 123 124 125 126 file.txt file2.txt
In file.txt there is a line that reads: [backup 123 full type etc etc]
This tells me the FULL backup is in the 123 directory (the data right in front of the word FULL)
I then need to tar or cp the 123 directory.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello
Pls help me i need script for counting number of fails from file .
The file contains number of failuer records . (2 Replies)
Discussion started by: getdpg
2 Replies
2. Shell Programming and Scripting
Hi,
I have a file which computes fields number and some column produced "nan"
I would like to convert the "nan" value to 0 basically.
q=`echo $i $j |awk '{printf("%f",($2/($1+$2)))}'
The above is the command which I use for computation. However, I would
like to check if $1 and $2 is 0, it... (1 Reply)
Discussion started by: ahjiefreak
1 Replies
3. Shell Programming and Scripting
Hi Guys,
I need to set the value of $7 to zero in case $7 is NULL. I've tried the below command but doesn't work. Any ideas. thanks guys.
MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else { print $7}}' `
Harby. (4 Replies)
Discussion started by: hariza
4 Replies
4. Shell Programming and Scripting
helo all
i have 2 files. and i want to grep the contents of first file from the 2nd file. but these files are too large contaning lacks of lines .
i'm using for loop but it takes so moch times . is there any other sol.
i'm using this code
"
for var in `cat succ_migrated`
do
grep $var... (4 Replies)
Discussion started by: dodasajan
4 Replies
5. Shell Programming and Scripting
I am wondering if there is a way via grep and sed to extract a string that is on the 2nd line below a known marker as in this example:
TextRel 203 0 0 "WELL:"
SetPosAbs 1287 -6676
TextRel 210 0 0 "AEP #2"
The marker is WELL:, but the string I need is "AEP #2". Can grep/sed handle this... (19 Replies)
Discussion started by: phudgens
19 Replies
6. Shell Programming and Scripting
Hi,
My log file is something like this.
(08/04/2009 00:27:42.179)(:) aaaaaaaaaaaa
(08/04/2009 00:27:42.181)(:) bbbbbbbbbbbbbbbb
(08/04/2009 01:00:42.713)(:) cd cdc d ddddsksjdkssksksj
(08/04/2009 01:02:42.716)(:) raarrarararararara
(08/04/2009 01:07:43.036)(:ERROR) Port... (8 Replies)
Discussion started by: rdhanek
8 Replies
7. UNIX for Dummies Questions & Answers
Hello,
I'm working on unix with grep (GNU grep) 2.5.1. I'm going through some of the newer regex syntax using Regular Expression Reference - Advanced Syntax a guide.
ls -aLl /bin | grep "\(x\)"
Which works, just highlights 'x' where ever, when ever.
I'm trying to to get (?:) to work but... (4 Replies)
Discussion started by: MykC
4 Replies
8. Shell Programming and Scripting
Hi,
I have one file, say file 1, that has data like below where 19900107 is the date,
19900107 12 144 129 0.7380047
19900108 12 168 129 0.3149017
19900109 12 192 129 3.2766666E-02
... (3 Replies)
Discussion started by: Wynner
3 Replies
9. Shell Programming and Scripting
I would like to search for regex in the exif data of a large collection of files (mostly jpg, some nef). For instance "grep_exif Tokyo *.jpg" should return the file names of all files which have "Tokyo" in their exif data.
Exiftool could be used to extract the data. I don't really need to grep... (6 Replies)
Discussion started by: bamse
6 Replies
10. Shell Programming and Scripting
i have this line of code that looks for the same file if it is currently running and returns the count.
`ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l`
basically it is assigned to a variable
ISRUNNING=`ps -eaf -o args | grep -i sfs_pcard_load_file.ksh |... (6 Replies)
Discussion started by: wtolentino
6 Replies
LN(1) FSF LN(1)
NAME
ln - make links between files
SYNOPSIS
ln [OPTION]... TARGET [LINK_NAME]
ln [OPTION]... TARGET... DIRECTORY
ln [OPTION]... --target-directory=DIRECTORY TARGET...
DESCRIPTION
Create a link to the specified TARGET with optional LINK_NAME. If LINK_NAME is omitted, a link with the same basename as the TARGET is
created in the current directory. When using the second form with more than one TARGET, the last argument must be a directory; create
links in DIRECTORY to each TARGET. Create hard links by default, symbolic links with --symbolic. When creating hard links, each TARGET
must exist.
Mandatory arguments to long options are mandatory for short options too.
--backup[=CONTROL]
make a backup of each existing destination file
-b like --backup but does not accept an argument
-d, -F, --directory
hard link directories (super-user only)
-f, --force
remove existing destination files
-n, --no-dereference
treat destination that is a symlink to a directory as if it were a normal file
-i, --interactive
prompt whether to remove destinations
-s, --symbolic
make symbolic links instead of hard links
-S, --suffix=SUFFIX
override the usual backup suffix
--target-directory=DIRECTORY
specify the DIRECTORY in which to create the links
-v, --verbose
print name of each file before linking
--help display this help and exit
--version
output version information and exit
The backup suffix is `~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX. The version control method may be selected via the --backup
option or through the VERSION_CONTROL environment variable. Here are the values:
none, off
never make backups (even if --backup is given)
numbered, t
make numbered backups
existing, nil
numbered if numbered backups exist, simple otherwise
simple, never
always make simple backups
AUTHOR
Written by Mike Parker and David MacKenzie.
REPORTING BUGS
Report bugs to <bug-coreutils@gnu.org>.
COPYRIGHT
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU-
LAR PURPOSE.
SEE ALSO
The full documentation for ln is maintained as a Texinfo manual. If the info and ln programs are properly installed at your site, the com-
mand
info ln
should give you access to the complete manual.
ln (coreutils) 4.5.3 February 2003 LN(1)