Programming :: List All The Files That Don't Contain Pattern1 And Append A New String?
Mar 24, 2011
How to list all the files that don't contain pattern1 and append a new line (pattern1) to those files before pattern2 only once.
pattern1 = /var/script/showMessage.sh
pattern2 = ;;
Code:
grep -c 'pattern1' /var/script/*_cam* | grep :0 | add pattern1 before pattern2 in each file loacted before.
View 10 Replies
ADVERTISEMENT
Sep 20, 2009
I'm having problems completing my school exercises with awk.
Heres the desired outcome:
Code:
./my_awk 2
ACG GAG ATT AGG AGG ATC CCA CCA
CAC AGG ACG GAG ATT AGG AGG ATC
So it generates data in group of threes, 8 groups per row and prints it. My problem is that I can't seem to get awk to append stuff to string so I could print it nicely to screen. It just prints empty lines per the parameter given to it.
Heres my code so far:
Code:
#!/bin/sh
awk -v rows=$1 '
BEGIN {
[code]....
View 2 Replies
View Related
Apr 9, 2010
I have a requirement like this..this just a sample script...
Code:
when i run this scipt...
Code:
Code:
It is appended in the same line...
I want it to be added to the next line.....
I want to do this by explitly using the filehandles in perl....and not with redirection operators in shell.
View 1 Replies
View Related
May 19, 2011
I have the following function that does not iterate through the array I want to be able to do some manipulation on each element in the array[@].it appears the below array has only one item in the array whereas i want the array to have 3 items hence the loop three times printing the message Any ideas why this is not happening ?
function foo() {
name =$1
array=( "$2" )
[code]...
View 5 Replies
View Related
Jun 8, 2010
I want to append a variable string to the end of a specific line. not like append the same string to each line. like in my file i have 4 columns, i want to add a string in 5th column in some fixed row.
View 4 Replies
View Related
Apr 13, 2010
I have my own declared types and I have to operate with lists of items. I wish to write a one macro, instead of using a function for each type. It's intended to be like this: Code: #define ____append_to_list(head,
item, type)
type* ptr;
for ( ptr = head; ptr->next != NULL; ptr = ptr->next )
[code].....
View 9 Replies
View Related
Dec 30, 2010
If I do:
for i in $(cat names); do seq -f "$i%03.0f" 0 999; done > output5.txt
I got ( tail snipped):
997munt
998munt
999munt
If I do:
for i in $(cat names); do seq -f "%03.0f$i" 0 999; done > output4.txt
I got:
997Zygmunt
998Zygmunt
999Zygmunt
How I can get numbers from 000 to 999 appended like:
Zygmunt997
Zygmunt998
Zygmunt999
View 8 Replies
View Related
Jun 14, 2011
From a file I want to extract a range of lines by patterns. I've used variations on
Code:
sed -n -e '/^BashNotes/,/^EndOf[A-Za-z]*$/ p' -e '/^EndOf[A-Za-z]*$/ q' Notes
So, I want to extract lines starting from one whose first word is specified, in this case "BashNotes", and ending at the first line consisting of the single word "EndOf...", which in this case would be "EndOfBashNotes".
Either I get no output at all, or it prints from the start of file to the first EndOf..., so the problem has to be with "^BashNotes", e.g. remove the "^" and it accesses an earlier occurrence of "BashNotes" that is in the middle of the first line of the file, and prints to the first occurrence of "EndOf...".
So why should a "^" in the "from" pattern be objectionable, when it is acceptable in the "to" pattern and the "quit" statement?
View 7 Replies
View Related
Jan 24, 2011
How can I list string indexes from an array in ksh ?
View 4 Replies
View Related
Jun 4, 2010
How can i split a string like this,
Code:
This is my first line.
This is my second line.
This is my third line.
into,
Code:
"This is my first line.", "This is my second line.", "This is my third line."
in C++.
i.e. split the code at every new line
View 11 Replies
View Related
Feb 10, 2009
I am trying to get this script to work. The purpose is to download a list of modules from the slax.org the list consist of a list of module numbers. What I am trying to do is Download the file or the file name corresponding to the number in the list.the list is comma delimited. this is what I have done so far and I am a stand still.
#!/bin/sh
# Wget script to retrieve modules from slax.org modules
#
# ----Begin of user defined values -----
# Path to wget
[code].....
View 7 Replies
View Related
Oct 22, 2010
copy string a to string b and change string b with toupper() and count the chars
View 3 Replies
View Related
Mar 10, 2011
How can I search for a string (for example, a constant) in all the (.cpp) files in the current direcotire and subdiretories.
View 4 Replies
View Related
Oct 30, 2010
I used a command Code:
grep -r err_sys ./
its output is
Code:
./tcpclitime.c:err_sys("socket error");
./tcpclitime.c:err_sys("connect error");
./tcpclitime.c:err_sys("write error");
./tcpclitime.c:err_sys("shutdown error");
./tcpclitime.c:err_sys("read error, n = %d", n);
[Code].....
Is it possible some how to replace all the occurrences of word err_sys by printf.
View 1 Replies
View Related
Apr 8, 2009
I am web developer I have this command find . -exec grep "Improve your score" '{}' ; -print for searching through files . I found this command but now i would like to tweak it to gain more out of it.
View 2 Replies
View Related
May 9, 2011
I'm trying to search the string "Listen" in a few files (config files). I madefind /apps/apache* -exec grep -H Listen {} ;but the result list is very long. How i make a "grep -v" whith this command?
View 3 Replies
View Related
May 3, 2011
I've been trying to understand pthread in C a little better. So I made a simple program that takes in a string from the command line and creates a thread to print the string. I've looked online and copied the basic concepts but there are something things I'm confused about. The programs works just fine, but I have questions. Here's what I have so far.
[Code]....
One thing I'd like to know is why the 3rd argument in the pthread_create function which is my SendMessage function needs to be typecasted to a void pointer and then send the address of the function. Also as for the 4th argument, I would see typecasting to void pointer in some of the pthread examples I saw online, but in my case I'm passing a char pointer, would this be correct? In which case would I ever want to pass a void pointer?
Do I need a pthread_exit(NULL) in my main and in the SendMessage function? If so, why? I added the sleep() function so that I could let the pthread_exit function in my SendMessage function execute first. I simply saw that the online examples on pthread had pthread_exit() in both locations.
View 6 Replies
View Related
Dec 8, 2010
I am an uploader to a various hosts, so this tiny script me a lot. I make a rar archive and split files with 100mb. I could get 3-4 or even 76 parts of rar files and it would take me some time to paste all these urls to remote upload function of filehosting sites. For example:
Code:
server:/home/cober/downloads/teevee# ls -al
total 358784
drwxrwxrwx 2 root root 4096 Dec 8 19:38 .
[code]....
View 1 Replies
View Related
Oct 16, 2010
I have a set of lines as ahown below:
Leon went to school
Leon came back from school..
Leon had dinner...
I have to replace the line containing "dinner" by a single string LUNCH...
View 2 Replies
View Related
Feb 25, 2011
I need to creates string suffixes out of a Reference string. for eg. suffixes of abcdefg will be
1)bcdefg
2)cdefg
3)defg
and so on...
create an array of pointers to point to the first few characters and then use that pointer to print the rest of the string.But when i print using the pointer i get GARBAGE values! shudn't std::cout<<ptr[w] print the string following the char it is pointing to? why do i get garbage values?
View 9 Replies
View Related
Apr 18, 2010
So if I'm given a location of a file like:
How can I just take the type of the file at the end? I know I can use strrchr() for a period to get the pointer to the period just before file type. Is there a build in string function that will just take the rest of the string from a certain point on forward in the string? I know it wouldn't be much work to make it myself, but I figured I would find out if it already existed before doing it.
View 9 Replies
View Related
Mar 13, 2010
Code:
The error is:
Code:
What I want to do is take input of ip4 as a string, convert it to an integer to add 1 to it, then reconvert it back to a string. Its not working.
My full code is:
Code:
View 1 Replies
View Related
Mar 12, 2011
I have to display from the list of files given as parameters the name of the file with the largest number of words and their number.(with AWK)
View 2 Replies
View Related
Jul 12, 2009
Is there a way, preferably in python or BASH, to rename files from a list? for instance, track1.mp3, track2.mp3 should be renamed to the names stored in a file listing song names. I have tried to loop a variable through directory listing and renamed them, only to find that filenames with spaces can't be assigned to a variable as a whole. To solve the problem above, I have tried the read command in BASH, which enables the program reading line by line from a list. However, It was failed to pipe the results from directory listing to the read command.
View 14 Replies
View Related
Feb 15, 2010
How to list only hidden files in current directory ?
View 2 Replies
View Related
Jul 8, 2011
I ran the command:
Code:
ls -ltr | head -n40
I'd like to delete all the files listed...
View 2 Replies
View Related
Oct 17, 2009
I need to, through a bash script, go through a given directory (given as argument 1) to list out the relative path in this directory (including $1) for eact subdirectory which contains files. Directories which only contain . .. and eventually only subdirectories SHALL NOT be listed. It is this last requirement that makes it difficult for me.
I have been using the tree command for now, but I have not found a way to ignore paths to directories which only contains other subdirs or nothing at all in any easy way. I may offcourse test each directory after they are listed but this gives an extra loop to go through and I beleive it should be possible to do it directly when creatring the list. I guess by using find or ls in conjuntion with the tree command or by itself it should be possible but I am not to conversant of nested script commands.
View 9 Replies
View Related
Oct 12, 2009
I've been given a custom-made string class which handles string, wstring and bstr. It has a number of methods and assignment operators to convert to and from different types. The app I work on compiles happily in VS6 and VS2008, but when trying to compile in Redhat (version 4.1.1 in Redhat 5.0)
[code]....
View 4 Replies
View Related
Nov 11, 2010
I have the following two type of strings1: A/D2: A/C/DI am trying to write a subroutine to check whether all of the letters in string 1 appears in string 2. If yes, return true. If not, return false. In the above example, all the letters (A and D) in string 1 are also present in string 2, so I return true.
View 4 Replies
View Related
Aug 10, 2010
The s means substitute
The $ in this particular regex (regular expression) means end of the line.
The ; is what you're subbing. This works fine and well, but what if you want to append a / at the end of the line?
sed 's/$///' filename doesn't work.
View 1 Replies
View Related