Sponsored Content
Top Forums Shell Programming and Scripting Read File and use contents to rename another Post 302291350 by ShawnMilo on Wednesday 25th of February 2009 12:15:33 PM
Old 02-25-2009
Quote:
Originally Posted by Shark Tek
I don't have to python on the machine and to have it I have to do a request that will take a very long time.
Okay, here's an ugly Perl one-liner:

Code:
cat test.dat  | perl -ne ' if ($. < 5){$_ =~ s/^.*:\s*(\S+).*\n$/$1/; $newName = $newName . $_ . "-"}else{$newName =~ s/-$//; print $newName; exit;}'

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to read the contents of a file using PERL

Hi My requirement is to read the contents of a fixed length file and validate the same. But am not able to read the contents of the file and when i tried it to print i get <blank> as an output... I used the below satatements for printing the contents ... (3 Replies)
Discussion started by: meva
3 Replies

2. Shell Programming and Scripting

Read contents from a file

Hi Friends, I am new to this forum. Just struck up with a logic. I have a csv file seperated by ":" (colons). This csv file contains hostname and groups as follows: HOSTNAME:VT Group SGSGCT2AVPX001:Team1 SGSGCT2AVPX003:Team2 SGSGCT2AVPX005:Team2 PHMNCTTAVPX001:Team3 I want to... (2 Replies)
Discussion started by: dbashyam
2 Replies

3. Shell Programming and Scripting

How to read contents of a file into variable :(

My file is in this format : username : student information : default shell : student ID Eg : joeb:Joe Bennett:/bin/csh:1234 jerryd:Jerry Daniels:/bin/csh:2345 deaverm: Deaver Michelle:/bin/bash:4356 joseyg:Josey Guerra:/bin/bash:8767 michaelh:Michael Hall:/bin/ksh:1547 I have to... (1 Reply)
Discussion started by: dude_me5
1 Replies

4. Shell Programming and Scripting

how to read contents of file?

I have made a script something like this. I want it to read the contents of either file or directory but 'cat' and 'ls' is not working. Can anyone help me? I am a newbie in scripting so dont know much about it. I also dont know how can i put my code separatly on this forum #!/bin/bash echo... (9 Replies)
Discussion started by: nishrestha
9 Replies

5. Programming

read() contents from a file

Hi, I'm trying to implement a C program on ubuntu which reads the contents of a file that is passed in as an argument and then displays it to the screen. So far I've cobbled together this from bits online but most of it is probably wrong as its all copied and pasted... #include <stdio.h>... (2 Replies)
Discussion started by: cylus99
2 Replies

6. Shell Programming and Scripting

read contents of a file using AWK

Hi, I am kind of new at awk programming, so any help would be great ! I am trying to read a date from a file into a variable and a count into another variable and display both these variables. The file looks like the attached file... I tried this but it doesn't work ... ... (6 Replies)
Discussion started by: RDR
6 Replies

7. Shell Programming and Scripting

Replace partial contents of file with contents read from other file

Hi, I am facing issue while reading data from a file in UNIX. my requirement is to compare two files and for the text pattern matching in the 1st file, replace the contents in second file by the contents of first file from start to the end and write the contents to thrid file. i am able to... (2 Replies)
Discussion started by: seeki
2 Replies

8. Shell Programming and Scripting

How to read contents in each file and rename the file?

Hello All, Can you help me in writing a script for reading the specific position data in a file and if that data found in that file that particular file should be renamed. Ex: Folder : C:\\test and Filename : CLSACK_112214.txt,CLSACK_112314.txt,CLSACK_112414.txt Contents in the file would... (3 Replies)
Discussion started by: nanduedi
3 Replies

9. Shell Programming and Scripting

Remove or rename based on contents of file

I am trying to use the two files shown below to either remove or rename contents in one of those files. If in file1.txt $5 matches $5 of file2.txt and the value in $1 of file1.txt is not "No Match" then that value is substituted for all values in $5 and $1 of file2.txt. If however in $1 ... (5 Replies)
Discussion started by: cmccabe
5 Replies

10. UNIX for Beginners Questions & Answers

Rename file in directory using contents within each file

In the below there are two generic .vcf files (genome.S1.vcf and genome.S2.vcf) in a directory. There wont always be two genaric files but I am trying to use bash to rename each of these generic files with specfic text (unique identifier) within in each .vcf. The text will always be different, but... (11 Replies)
Discussion started by: cmccabe
11 Replies
pop3d::udb(n)						      Tcl POP3 Server Package						     pop3d::udb(n)

NAME
pop3d::udb - Simple user database for pop3d SYNOPSIS
package require Tcl 8.2 package require pop3d::udb ?1.0? ::pop3d::udb::new ?dbName? dbName option ?arg arg ...? dbName destroy dbName add user pwd storage dbName remove user dbName rename user newName dbName lookup user dbName exists user dbName who dbName save ?file? dbName read file DESCRIPTION
The package pop3d::udb provides simple in memory databases which can be used in conjunction with the pop3 server core provided by the pack- age pop3d. The databases will use the names of users as keys and associates passwords and storage references with them. Objects created by this package can be directly used in the authentication callback of pop3 servers following the same interface as servers created by the package pop3d. ::pop3d::udb::new ?dbName? This command creates a new database object with an associated global Tcl command whose name is dbName. The command dbName may be used to invoke various operations on the database. It has the following general form: dbName option ?arg arg ...? Option and the args determine the exact behavior of the command. The following commands are possible for database objects: dbName destroy Destroys the database object. dbName add user pwd storage Add a new user or changes the data of an existing user. Stores password and storage reference for the given user. dbName remove user Removes the specified user from the database. dbName rename user newName Changes the name of the specified user to newName. dbName lookup user Searches the database for the specified user and returns a two-element list containing the associated password and storage refer- ence, in this order. Throws an error if the user could not be found. This is the interface as expected by the authentication call- back of package pop3d. dbName exists user Returns true if the specified user is known to the database, else false. dbName who Returns a list of users known to the database. dbName save ?file? Saves the contents of the database into the given file. If the file is not specified the system will use the path last used in a call to dbName read. The generated file can be read by the read method. dbName read file Reads the specified file and adds the contained user definitions to the database. As the file is actually source'd a safe inter- preter is employed to safeguard against malicious code. This interpreter knows the add command for adding users and their associated data to this database. This command has the same argument signature as the method add. The path of the file is remembered internally so that it can be used in the next call of dbName save without an argument. KEYWORDS
pop3, internet, network, protocol, rfc1939 pop3d 1.0 pop3d::udb(n)
All times are GMT -4. The time now is 01:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy