Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have to make a script using grep filtering a pattern in a 10 files that have been compressed tar format, this is what I have done until now.
#!/bin/sh
cd ../Data
ls *.tar #list file with extention tar
tar – xzvf *.tar > ../Result/file01.tar #decompress tar file and send to directory Result as
file01.tar
for i = 1; $i <=10; $i=++; #for i as the first file until the 10 th file find a pattern
from tar files in Data and send to Result directory as fileresult.out
My name is Adriana, and I have to make a script using grep filtering a pattern in a 10 files where are compress with tar, I hope to heard from you soon. thanks your very much
We are not going to write scripts for you, but we will be glad to HELP you. So, post what you've written/tried so far, and where you're stuck. Otherwise, you can read the man pages on the commands, and look up any of the VERY easily-found bash scripting tutorials on Google, and start there. Also, be aware that we aren't going to give you answers to homework questions, either.
In addition, tar is not a compression tool; it just collects all input into one big file archive.
If you created with with the z (gzip) or j (bzip2) flag, then it will be compressed as well.
If the archive is compressed, you will need to uncompress it first.
My name is Adriana, and I have to make a script using grep filtering a pattern in a 10 files where are compress with tar, I hope to heard from you soon. thanks your very much
sounds an awful lot like homework to me.
as stated post what you have done, we will be glad to help you fix your errors, but not do you homework for you as that is against forum rules.
as stated post what you have done, we will be glad to help you fix your errors, but not do you homework for you as that is against forum rules.
Sorry about this impression, It is my fault about my message, but I do not try that someone do the "homework" for my, how I can learn from it if I do not do an effort. Thanks you for take your time and answer my message
tar –xzvf Data_preg2.tar > ../Result_taller_eval #decompress tar file and send to directory Result as file01.tar
#for (my $i=1;$i<=10;$i++ #for i as the first tar file until the 10 th file find a pattern from tar files Data and send to Result directory fileresult.out
tar: opción incorrecta -- «�»
Intente`tar --help' o `tar --usage' para mayor información.
I when to man tar but I do not what to do
when I run all the script give me an error
./scriptgrep.sh: 10: Syntax error: Bad for loop variable
How I make an good for loop variable
grep "agcct" <(tar -tvf Data_preg2.tar) #list file with extention tar
#tar –xzvf Data_preg2.tar > ../Result_taller_eval #decompress tar file and send to directory Result as file01.tar
#for (my $i=1;$i<=10;$i++ #for i as the first tar file until the 10 th file find a pattern from tar files Data and send to Result directory fileresult.out
and the answer is cd ../Data_taller_eval/
+ cd ../Data_taller_eval/
grep "agcct" <(tar -tvf Data_preg2.tar) #list file with extention tar
./scriptgrep.sh: 8: Syntax error: "(" unexpected
I do not recognized what is the syntax error and how I make this with 10 file the last part I used for (my $i=1;$i<=10;$i++ but it also get error
while read -r file
do
grep 'agcct' $file
done < $(tar -tvf Data_preg2.tar)
and I get this
cd ../Data_taller_eval/
+ cd ../Data_taller_eval/
while read -r file
do
grep 'agcct' $file
done < $(tar -tvf Data_preg2.tar)
tar -tvf Data_preg2.tar)
tar -tvf Data_preg2.tar
++ tar -tvf Data_preg2.tar
tar: Data_preg2.tar: No se puede read: Es un directorio
tar: Al principio de la cinta, se terminará ahora
tar: Error is not recoverable: exiting now
tar -tvf Data_preg2.tar)
tar -tvf Data_preg2.tar
++ tar -tvf Data_preg2.tar
tar: Data_preg2.tar: No se puede read: Es un directorio
tar: Al principio de la cinta, se terminará ahora
tar: Error is not recoverable: exiting now
./scriptgrep1.sh: línea 11: $(tar -tvf Data_preg2.tar): redireccionamiento ambiguo
line 11 is ambiguos and how I can to make this to 10 file ?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.