Sponsored Content
Top Forums Shell Programming and Scripting Match and variable length string Post 302578301 by CarloM on Thursday 1st of December 2011 09:12:53 AM
Old 12-01-2011
Are you going to be filtering on specific record (NAME2) values? As in, why are you setting RS?

Otherwise, you could just do:
Code:
awk -F= '/TZ/ {print $2}' toto.txt

This might work with RS:
Code:
 awk 'BEGIN { RS=";;"; FS="[)= ]" } /TZ/ { for (i=1;i<NF;i++) { if ($i ~ /TZ$/) { print $(i+1) }}}' toto.txt

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding out the length of a string held within a variable

:confused: Does anyone know which command I can use to find out the length of a string held within a variable? (5 Replies)
Discussion started by: dbrundrett
5 Replies

2. Shell Programming and Scripting

creating a fixed length output from a variable length input

Is there a command that sets a variable length? I have a input of a variable length field but my output for that field needs to be set to 32 char. Is there such a command? I am on a sun box running ksh Thanks (2 Replies)
Discussion started by: r1500
2 Replies

3. Shell Programming and Scripting

Replace variable length numeric string

I have a customer who logged some cc and bank account numbers in their apache logs. I got the cc numbers x'd out with sed -e 's/args=\{16\}/args=XXXXXXXXXXXXXXXX/g' -e 's/cardnum=\{16\}/cardnum=XXXXXXXXXXXXXXXX/g'but that wasn't too difficult due to the value being 16 digits. The bank account... (7 Replies)
Discussion started by: mk4mzid
7 Replies

4. Shell Programming and Scripting

Replacing one Char in a string of variable length

Hi all, I am trying to find the best way of making a change to 1 char in a string, the string can be between 1 and 14 characters. I am reading a line in from a file which contains 012341231231:2:102939283:NNN: Require :NBN: 012838238232:3:372932:NNN: Require :NNB: I need to change 1 N or a... (8 Replies)
Discussion started by: nkwilliams
8 Replies

5. Shell Programming and Scripting

Make variable length record a fixed length

Very, very new to unix scripting and have a unique situation. I have a file of records that contain 3 records types: (H)eader Records (D)etail Records (T)railer Records The Detail records are 82 bytes in length which is perfect. The Header and Trailer records sometimes are 82 bytes in... (3 Replies)
Discussion started by: jclanc8
3 Replies

6. Shell Programming and Scripting

changing a variable length text to a fixed length

Hi, Can anyone help with a effective solution ? I need to change a variable length text field (between 1 - 18 characters) to a fixed length text of 18 characters with the unused portion, at the end, filled with spaces. The text field is actually field 10 of a .csv file however I could cut... (7 Replies)
Discussion started by: dc18
7 Replies

7. Shell Programming and Scripting

Extracting substrings from a string of variable length

I have a string like Months=jan feb mar april x y .. Here the number of fields in Months is not definite I need to extract each field in the Months string and pass it to awk . Don't want to use for in since it is a loop . How can i do it (2 Replies)
Discussion started by: Nevergivup
2 Replies

8. Shell Programming and Scripting

Sed:- Supported variable replacement after string match?

Hi All, I am trying to replace the variable in the file after the particular match string. It is being replaced if i hardcode the value and with use of "&" with sed. sed -e "s/URL./& http:\\localhost:7223/g" But when am trying to pass the variable it is failing. I tried multiple... (9 Replies)
Discussion started by: sharsour
9 Replies

9. Shell Programming and Scripting

Convert variable length record to fixed length

Hi Team, I have an issue to split the file which is having special chracter(German Char) using awk command. I have a different length records in a file. I am separating the files based on the length using awk command. The command is working fine if the record is not having any... (7 Replies)
Discussion started by: Anthuvan
7 Replies

10. UNIX for Beginners Questions & Answers

Views How to replace a CRLF char from a variable length file in the middle of a string in UNIX?

My sample file is variable length, with out any field delimiters. It has min of 18 chars length and the 'CRLF' is potentially between 12-14 chars. How do I replace this with a space? I still want to keep end of record, but just want to remove these new lines chars in the middle of the data. ... (7 Replies)
Discussion started by: chandrath
7 Replies
SmbClient(3pm)						User Contributed Perl Documentation					    SmbClient(3pm)

NAME
Filesys::SmbClient - Interface for access Samba filesystem with libsmclient.so SYNOPSIS
use POSIX; use Filesys::SmbClient; my $smb = new Filesys::SmbClient(username => "alian", password => "speed", workgroup => "alian", debug => 10); # Read a file my $fd = $smb->open("smb://jupiter/doc/general.css", '0666'); while (defined(my $l= $smb->read($fd,50))) {print $l; } $smb->close(fd); # ... See section EXAMPLE for others scripts. DESCRIPTION
Provide interface to access routine defined in libsmbclient.so provided with Samba. Since 3.0 release of this package, you need a least samba-3.0.2. For prior release of Samba, use Filesys::SmbClient version 1.x. For old and 2.x release, this library is available on Samba source, but is not build by default. Do "make bin/libsmbclient.so" in sources directory of Samba to build this libraries. Then copy source/include/libsmbclient.h to /usr/local/samba/include and source/bin/libsmbclient.so to /usr/local/samba/lib before install this module. If you want to use filehandle with this module, you need Perl 5.6 or later. When a path is used, his scheme is : smb://server/share/rep/doc VERSION
$Revision: 3.1 $ FONCTIONS
new %hash Init connection Hash can have this keys: o username o password o workgroup o debug o flags : See set_flag Return instance of Filesys::SmbClient on succes, die with error else. Example: my $smb = new Filesys::SmbClient(username => "alian", password => "speed", workgroup => "alian", debug => 10); set_flag Set flag for smb connection. See _SMBCCTX->flags in libsmclient.h Flag can be: SMB_CTX_FLAG_USE_KERBEROS SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON Tie Filesys::SmbClient filehandle This didn't work before 5.005_64. Why, I don't know. When you have tied a filehandle with Filesys::SmbClient, you can call classic methods for filehandle: print, printf, seek, syswrite, getc, open, close, read. See perldoc for usage. Example: local *FD; tie(*FD, 'Filesys::SmbClient'); open(FD,"smb://jupiter/doc/test") or print "Can't open file:", $!, " "; while(<FD>) { print $_; } close(FD); or local *FD; tie(*FD, 'Filesys::SmbClient'); open(FD,">smb://jupiter/doc/test") or print "Can't create file:", $!, " "; print FD "Samba test"," "; printf FD "%s", "And that work ! "; close(FD); Directory mkdir FILENAME, MODE Create directory $fname with permissions set to $mode. Return 1 on success, else 0 is return and errno and $! is set. Example: $smb->mkdir("smb://jupiter/doc/toto",'0666') or print "Error mkdir: ", $!, " "; rmdir FILENAME Erase directory $fname. Return 1 on success, else 0 is return and errno and $! is set. ($fname must be empty, else see rmdir_recurse). Example: $smb->rmdir("smb://jupiter/doc/toto") or print "Error rmdir: ", $!, " "; rmdir_recurse FILENAME Erase directory $fname. Return 1 on success, else 0 is return and errno and $! is set. Il $fname is not empty, all files and dir will be deleted. Example: $smb->rmdir_recurse("smb://jupiter/doc/toto") or print "Error rmdir_recurse: ", $!, " "; opendir FILENAME Open directory $fname. Return file descriptor on succes, else 0 is return and $! is set. readdir FILEHANDLE Read a directory. In a list context, return the full content of the directory $fd, else return next element. Each elem is a name of a directory or files. Return undef at end of directory. Example: my $fd = $smb->opendir("smb://jupiter/doc"); foreach my $n ($smb->readdir($fd)) {print $n," ";} close($fd); readdir_struct FILEHANDLE Read a directory. In a list context, return the full content of the directory FILEHANDLE, else return next element. Each element is a ref to an array with type, name and comment. Type can be : SMBC_WORKGROUP SMBC_SERVER SMBC_FILE_SHARE SMBC_PRINTER_SHARE SMBC_COMMS_SHARE SMBC_IPC_SHARE SMBC_DIR SMBC_FILE SMBC_LINK Return undef at end of directory. Example: my $fd = $smb->opendir("smb://jupiter/doc"); while (my $f = $smb->readdir_struct($fd)) { if ($f->[0] == SMBC_DIR) {print "Directory ",$f->[1]," ";} elsif ($f->[0] == SMBC_FILE) {print "File ",$f->[1]," ";} # ... } close($fd); closedir FILEHANDLE Close directory $fd. Files stat FILENAME Stat a file FILENAME. Return a list with info on success, else an empty list is return and $! is set. List is made with: o device o inode o protection o number of hard links o user ID of owner o group ID of owner o device type (if inode device) o total size, in bytes o blocksize for filesystem I/O o number of blocks allocated o time of last access o time of last modification o time of last change Example: my @tab = $smb->stat("smb://jupiter/doc/tata"); if ($#tab == 0) { print "Erreur in stat:", $!, " "; } else { for (10..12) {$tab[$_] = localtime($tab[$_]);} print join(" ",@tab); } fstat FILEHANDLE Like stat, but on a file handle rename OLDNAME,NEWNAME Changes the name of a file; an existing file NEWNAME will be clobbered. Returns true for success, false otherwise, with $! set. Example: $smb->rename("smb://jupiter/doc/toto","smb://jupiter/doc/tata") or print "Can't rename file:", $!, " "; unlink FILENAME Unlink FILENAME. Return 1 on success, else 0 is return and errno and $! is set. Example: $smb->unlink("smb://jupiter/doc/test") or print "Can't unlink file:", $!, " "; open FILENAME open FILENAME, MODE Open file $fname with perm $mode. Return file descriptor on success, else 0 is return and $! is set. Example: my $fd = $smb->open("smb://jupiter/doc/test", 0666) or print "Can't read file:", $!, " "; my $fd = $smb->open(">smb://jupiter/doc/test", 0666) or print "Can't create file:", $!, " "; my $fd = $smb->open(">>smb://jupiter/doc/test", 0666) or print "Can't append to file:", $!, " "; read FILEHANDLE read FILEHANDLE, LENGTH Read $count bytes of data on file descriptor $fd. It lenght is not set, 4096 bytes will be read. Return buffer read on success, undef at end of file, -1 is return on error and $! is set. FILEHANDLE must be open with open of this module. write FILEHANDLE, $buf write FILEHANDLE, @buf Write $buf or @buf on file descriptor $fd. Return number of bytes wrote, else -1 is return and errno and $! is set. Example: my $fd = $smb->open(">smb://jupiter/doc/test", 0666) or print "Can't create file:", $!, " "; $smb->write($fd, "A test of write call") or print $!," "; $smb->close($fd); FILEHANDLE must be open with open of this module. seek FILEHANDLE, POS Sets FILEHANDLE's position, just like the "fseek" call of "stdio". FILEHANDLE may be an expression whose value gives the name of the filehandle. The values for WHENCE is always SEEK_SET beacause others didn't work on libsmbclient.so FILEHANDLE must be open with open of this module. close FILEHANDLE Close file FILEHANDLE. Return 0 on success, else -1 is return and errno and $! is set. Print method unlink_print_job PRINTER_URL, IDJOB Remove job number IDJOB on printer PRINTER_URL print_file DOCUMENT_URL, PRINTER_URL Print file DOCUMENT_URL on PRINTER_URL TODO
o chown o chmod o open_print_job o telldir o lseekdir EXAMPLE
This module come with some scripts: t/*.t Just for check that this module is ok :-) smb2www-2.cgi A CGI interface with these features: o browse workgroup ,share, dir o read file o upload file o create directory o unlink file, directory COPYRIGHT
The Filesys-SmbClient module is Copyright (c) 1999-2003 Alain BARBET, France, alian at cpan.org. All rights reserved. You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file. perl v5.14.2 2006-09-13 SmbClient(3pm)
All times are GMT -4. The time now is 01:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy