Sponsored Content
Top Forums Shell Programming and Scripting BASH script to read external file to perform text replacements? Post 302975297 by RudiC on Friday 10th of June 2016 01:02:02 PM
Old 06-10-2016
How about
Code:
awk 'NR==FNR {T[$1] = $NF; next} $3 in T {$3 = T[$3]} 1' FS=":" file1 FS="," OFS="," file2
Date,Title,Views,Source
21-05-16,ProdA,this_title_now_conforms,487,YouTube
26-05-16,ProdA,this_title_is_not_so_bad,38,YouTube
14-06-16,ProdB,how_to_format_reports,83,YouTube
22-06-16,ProdC,formatting_source_reports,129,Internal

I'm inclined to bet that your ~300 lines bash can be boiled down to 20 - 30 lines awk.
This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script does not read the last line of text file

Hello, I have got a script that reads a text file, and have got three problems that I an struggling with. 1. The script does not read the last line in the text file 2. within the second 'elif' within the script I included a 'break' - the script runs successfully (except for the first... (2 Replies)
Discussion started by: jermaine4ever
2 Replies

2. Shell Programming and Scripting

Bash Script to read a file and parse each record

Hi Guys, I am new to unix scripting and I am tasked to parse through a CSV file delimited by #. Sample: sample.csv H#A#B#C D#A#B#C T#A#B#C H = Header D = Detail Record T = Tail What I need is to read the file and parse through it to get the columns. I have no idea on how... (8 Replies)
Discussion started by: 3vilwyatt
8 Replies

3. Shell Programming and Scripting

How to read the data from the text file in shell script?

I am having one text file and i need to read that data from my shell script. I will expain you the scenario: Script look like: For name type 1: For age type 2: For Salary type3: echo "Enter the input:" read the data if input is 1 then go to the Text file and print the... (2 Replies)
Discussion started by: dineshmurs
2 Replies

4. Shell Programming and Scripting

importing functions from an external bash script

Hi all, I'm trying to import some functions I have saved in a file named functions.sh into a different script (protocol.sh). Can anybody show me how to do this? I tried source functions.sh as I would do at the terminal but source command cannot be found from within the script protocol.sh. ... (2 Replies)
Discussion started by: tevang
2 Replies

5. Shell Programming and Scripting

Bash script to read file location

I'm writing a bash script that reads a file location from a user, and I'm wondering how to get the script to accept tab to auto complete the directories that are input. (8 Replies)
Discussion started by: Prodiga1
8 Replies

6. Shell Programming and Scripting

shell script to take input from a text file and perform check on each servers and copy files

HI all, I want to script where all the server names will be in a text file like server1 server2 server3 . and the script should take servernames from a text file and perform copy of files if the files are not present on those servers.after which it should take next servername till the end of... (0 Replies)
Discussion started by: joseph.dmello
0 Replies

7. Shell Programming and Scripting

How to Read different values from external file?

Hi , I am new to this scripting , I am facing an issue like how to read different values from external file by using different variables, In script I supposed to declare var 1 var 2 var 3 I know how to call this variables from external file (I am using awk command by giving same... (3 Replies)
Discussion started by: chandini
3 Replies

8. Shell Programming and Scripting

Bash Script Help...search then read from file: change text and pipe back...

Hello, I am trying to make a bash script that can pull data from a file and then change one part of said data. I want to search by username and pull the full line. That way there is a way to replace just one part of that line then return it back to the file. My Data is stored like: ... (1 Reply)
Discussion started by: serverfull
1 Replies

9. Homework & Coursework Questions

Shell Script to read a tab delimited file and perform simple tasks

1. The problem statement, all variables and given/known data: Hello! I need help with this problem bash shell scripting that basically just reads the data in a tab delimited file and does the following below 1. Read in the data file Survey.txt and assign the column values to variables of... (6 Replies)
Discussion started by: jsmith6932
6 Replies

10. Shell Programming and Scripting

Read variables from a text file for use in csh script

Hello, I have a text file (say, declarevars.txt) that contains multiple lines that are essentially meant to be variable declarations: set arr1 = (var1a var1b var1c) set arr2 = (var2a var2b var2c) . . . I want to be able to read this text file within a csh (sorry) script and have that... (2 Replies)
Discussion started by: arjaydj
2 Replies
WebService::YouTube::Util(3pm)				User Contributed Perl Documentation			    WebService::YouTube::Util(3pm)

NAME
WebService::YouTube::Util - Utility for WebService::YouTube VERSION
This document describes WebService::YouTube::Util version 1.0.3 SYNOPSIS
use WebService::YouTube::Util; # Get an URI of RSS my $uri = WebService::YouTube::Util->rss_uri( 'global', 'recently_added' ); # Get an URI of REST API my $uri = WebService::YouTube::Util->rest_uri( $dev_id, 'youtube.videos.list_by_tag', { tag => 'monkey' } ); # Get a downloadable URI my $uri = WebService::YouTube::Util->get_video_uri('rdwz7QiG0lk'); # Get a video which type is .flv my $content = WebService::YouTube::Util->get_video('rdwz7QiG0lk'); DESCRIPTION
This is an utility for WebService::YouTube. SUBROUTINES
/METHODS rss_uri( $type, $arg ) Returns a URI of RSS. $type should be 'global' or 'tag' or 'user'. $arg is required when $type is 'tag' or 'user'. rest_uri( $dev_id, $method, \%fields ) Returns a URI of REST API. $dev_id is your developer ID of YouTube. $method is a method name like a 'youtube.*.*'. %fields can contain optional parameter. get_video_uri( $video, \%args ) Returns a downloadable URI of $video. $video should be a video ID or a WebService::YouTube::Video object. %args can contain some optional arguments. ua LWP::UserAgent object get_video( $video, \%args ) Returns a downloaded content of $video. $video should be a video ID or a WebService::YouTube::Video object. %args can contain some optional arguments. ua LWP::UserAgent object DIAGNOSTICS
type of ... is not supported No such RSS. The type should be 'global' or 'tag' or 'user'. got a page but it is invalid page Maybe, YouTube is being maintained. :-) CONFIGURATION AND ENVIRONMENT
WebService::YouTube::Util requires no configuration files or environment variables. DEPENDENCIES
WebService::YouTube, LWP::UserAgent, URI::Escape INCOMPATIBILITIES
None reported. BUGS AND LIMITATIONS
No bugs have been reported. Please report any bugs or feature requests to "bug-webservice-youtube@rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WebService-YouTube>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. AUTHOR
Hironori Yoshida <yoshida@cpan.org> LICENSE AND COPYRIGHT
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic. perl v5.10.1 2009-01-20 WebService::YouTube::Util(3pm)
All times are GMT -4. The time now is 04:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy