Creating a one liner with wget, grep and mv


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Creating a one liner with wget, grep and mv
# 1  
Old 07-24-2009
Creating a one liner with wget, grep and mv

I have the following simplified script, that consists of a download (wget), a grab of only the lines with a comma (grep) and a rename of the file to indicate its date of origin (mv):
Code:
wget http://www.example.com/datafile.csv
grep ',' datafile.csv
mv datafile.csv datafile.`date +"%Y%m%d%H%M%S"`.csv

However, what i really want to do is create a one liner, such that I am not dependent on file names, but simply treat the downloaded file as one object. Hence, I need something like this:
Code:
wget http://www.example.com/datafile.csv | grep ',' > datafile.`date +"%Y%m%d%H%M%S"`.csv

How do I create a one liner for this? Thanks in advance
# 2  
Old 07-24-2009
Code:
wget --quiet http://www.example.com/datafile.csv -O - | grep ',' > datafile.`date +"%Y%m%d%H%M%S"`.csv

# 3  
Old 07-24-2009
Works great, thanks
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Wget, grep, sort, sed in 1 command/script

Hi, I need to join these statements for efficiency, and without having to make a new directory for each batch. I'm annotating commands below. wget -q -r -l1 URL ^^ can't use -O - here and pipe | to grep because of -r grep -hrio "\b\+@\+\.\{2,4\}\+\b" * > first.txt ^^ Need to grep the output... (14 Replies)
Discussion started by: p1ne
14 Replies

2. Shell Programming and Scripting

Wget - working in browser but cannot download from wget

Hi, I need to download a zip file from my the below US govt link. https://www.sam.gov/SAMPortal/extractfiledownload?role=WW&version=SAM&filename=SAM_PUBLIC_MONTHLY_20160207.ZIP I only have wget utility installed on the server. When I use the below command, I am getting error 403... (2 Replies)
Discussion started by: Prasannag87
2 Replies

3. OS X (Apple)

Having trouble creating an alias for grep

Hi, I'm using Mac 10.9.1. I would like to create an alias for grep so that it won't print out messages like "grep: /Users/davea/workspace/myproject/subdir/: Is a directory" all the time. So in my terminal, I opened ~/.profile and entered alias grep='grep -s' However, when I close and... (5 Replies)
Discussion started by: laredotornado
5 Replies

4. UNIX for Dummies Questions & Answers

Creating a loop to go through grep output

I'm doing this script in my Unix class and I've come to a roadblock. The purpose of this script is to search users directories for files that contain bad words i.e kill murder bomb etc., and then be able to ignore legitimate files with each use. I got the searching and ignoring part down but now... (1 Reply)
Discussion started by: jrod44
1 Replies

5. Shell Programming and Scripting

need a one liner to grep a group info from /etc/group and use that result to search passwd file

/etc/group tiadm::345:mk789,po312,jo343,ju454,ko453,yx879,iy345,hn453 bin::2:root,daemon sys::3:root,bin,adm adm::4:root,daemon uucp::5:root /etc/passwd mk789:x:234:1::/export/home/dummy:/bin/sh po312:x:234:1::/export/home/dummy:/bin/sh ju454:x:234:1::/export/home/dummy:/bin/sh... (6 Replies)
Discussion started by: chidori
6 Replies

6. UNIX for Dummies Questions & Answers

One liner pattern search with awk/sed/grep

I have an array containing bunch of characters. I have to check this array for specific character and if "Not Found than" use a goto statement to go to USAGE set options = (A B C D E F) @ i = 0 while ($i <= ${#options}) if ($options != "F" || $options != "D") then goto USAGE endif @... (1 Reply)
Discussion started by: dixits
1 Replies

7. Shell Programming and Scripting

Search & Replace regex Perl one liner to AWK one liner

Thanks for giving your time and effort to answer questions and helping newbies like me understand awk. I have a huge file, millions of lines, so perl takes quite a bit of time, I'd like to convert these perl one liners to awk. Basically I'd like all lines with ISA sandwiched between... (9 Replies)
Discussion started by: verge
9 Replies

8. Shell Programming and Scripting

grep-awk one liner help

Hi guys, I'm trying to create a one line command that does the following. I will post my command first so you can get the idea better: ls -larht | awk '{print $4}' | uniq | xargs grep * __________ ls -larht | awk '{print $4}' | uniq This will post the name of the groups of each file... (2 Replies)
Discussion started by: erick_tuk
2 Replies

9. Shell Programming and Scripting

creating a csv file from this 1 liner?

I'm trying to create a csv file by running awk and sed on a number of xml files in a directory; I'm using this below: hostname; grep "BuildDate" /dir/ABCD/configuration/*/*.xml | awk -F"/" '{ print $5 }' > /tmp/tempfile.txt; grep "BuildDate" /dir/ABCD/configuration/*/*.xml | awk -F\" '{ print $2... (2 Replies)
Discussion started by: rich@ardz
2 Replies

10. Shell Programming and Scripting

Grep/Awk WGet Time

I am trying to grep/awk how long it takes to get a page. I am trying to use the following command. time -p wget -q -O wget.tmp www.google.com 2>&1 | grep realThe problem is that my attempts to map stderr to stdout are being applied to wget not to time so all of the time output is displayed on... (2 Replies)
Discussion started by: wstrater
2 Replies
Login or Register to Ask a Question