1. Find all of the "*.tmp" files in a given user directory
2. Determine which ones have "find" in them.
3. Replace the "find sequence" of commands with a "list set" of commands.
Example:
Original file:
--------------
Final file should be:
---------------------
I am trying following code:
-----------------------------------
Please help.
Thank you,
Manish Kumar
---------- Post updated at 01:13 PM ---------- Previous update was at 11:59 AM ----------
In short, if I have following lines in my code :
Then I want to remove the lines having ;" and/or run just before the line having word list in it.
I know how to remove a line matching pattern using sed but don't know to remove lines before matching pattern.
Please help. It's urgent for me.
Many thanks in advance.
Last edited by manishdivs; 04-10-2013 at 06:23 AM..
Reason: typo
As you can see, it worked with my version. You now need to fiddle around with e.g. the /;\|run/d command, and others. Try /;/d;/run/d. Be creative.
Hello RudiC,
I did try several option but not getting success might be because I am not well versed with Unix.
I request you to please give me a separate command for reading the line beginning with list and removing the lines before that having ";: and/or "run".
I have on my machine:
grep -B is not working on my machine otherwise that easy to achieve.
for i in *.tmp; do cp "$i" "${i%.tmp}"_New.tmp; done
is nonsense, because the outer loop cycles through the .tmp files already.
Variables like $i should be quoted when used as command arguments.
You can also delete ";" and "run" with the sed command. The latter is left as an exercise (this smells like homework).
Last edited by MadeInGermany; 04-10-2013 at 05:53 AM..
Reason: "if grep"
I kept inner for loop my mistake. I was initially planning to take backup of the files then forgot to remove it from there.
This is not a homework, I stuck in between writing a command sequence upon request received from superior on an urgent basis. Any help will be really appreciated.
As you can see in my initial post that I already covered the parts of replacing find and with with their corresponding changes. I am only stuck to remove ; and/or run only from the lines occurring above line starting with word list.
I know the command to remove the single line using PATTERN, following is the code:
but I stuck for removing pattern only if occurs in above line where list keyword is found.
In your response, -e 's/^[[:blank:]]*;[[:blank:]]*$//' "$i".bak > "$i" code only replaces ; irrespective of checking that it should appear in above 1 or 2 lines where the code begins with list occurs.
Actually, I want to remove ; and/or run only from the lines occurring above line starting with word list.
I apologize if I am not clear in explaining the situation. Please let me know if I need to explain more.
Please help.
Thank you.
Last edited by manishdivs; 04-10-2013 at 06:39 AM..
Reason: typo
Hi, I need to print lines which are matching with start pattern "SELECT" and END PATTERN ";" and only select the last "select" statement including the ";" .
I have attached sample input file and the desired input should be as:
INPUT FORMAT:
SELECT
ABCD,
DEFGH,
DFGHJ,
JKLMN,
AXCVB,... (5 Replies)
Hi
I need to find files in a specified folder where are two specified lines of text and delate that lines. It looks like this"
35. ?>NL
36. <iframe>.......</iframe>NLThe problem is that "?>" is in the other lines and id should not be removed if the next line is not like "<iframe>....."
So... (4 Replies)
Hi
I need to remove three consecutive lines of code which appear multiple times during a script. Two of the lines also appear in other parts of the scripts and need to stay so I can't strip out the code per se - It needs to be the exact three lines. Hope that makes sense !
Any help much... (5 Replies)
Hello
I have been trying to remove a row from a file which has the same first three columns as another row - I have tried lots of different combinations of suggestion on this forum but can't get it exactly right.
what I have is
900 - 1000 = 0
900 - 1000 = 2562
1000 - 1100 = 0
1000 - 1100... (7 Replies)
Hey everyone, I have a question about comparing two files. I have two lists of files. The first list, todo.csv, lists a series of compounds my supervisor wants me to perform calculations on. The second list, done.csv, lists a series of compounds that I have already performed calculations on.... (2 Replies)
Hello everyone,
I have a fasta file in the following format:
>Sic_7657.x01 bhg|7675859 info:546474
ATGCTAGATGCTAGCTAGCTAGCTGCT
CGTAGCTAGTCGTAGCTGATGCTAGGC
CGATG
>Sic_7657.x1 bhg|76675 info:546474
CGATGCTGATGCTGATCGTGATCTGTC
CAGTCGAGCTGATGTCGTATGCGGGTG
GCTAGCTA
>Sic_7658.y1 bhg|76675... (3 Replies)
Hi Guru's , I have a whole bunch of files in /var/tmp that i need to strip any blank lines from, so ive written the following script to identify the lines (which works perfectly).. but i wanted to know, how can I actually strip the identified lines from the actual source files ??
my... (11 Replies)
Hi
I have some files that contain be anything up to 100k lines - eg. file100k
I have another file called file5k and I need to produce filec which will contain everything in file100k minus what matches in file 5k..
ie.
File100k contains
1FP
2FP
3FP
File5k contains
2FP
I would... (2 Replies)
Hi
I have a .conf file having many location tags like
<Location /main>
AuthName main
AuthUserFile /ppt/gaea/passwd_main
Require user admin
</Location>
......
...
<Location /wonder>
AuthName gaea
AuthUserFile /ppt/gaea/passwd_gaea
Require... (3 Replies)
Hi folks,
- I have 800 txt files
- those files are cisco router configs
router1.txt
router2.txt
...
router800.txt
I want to accomplish the following:
- I want to have a seperate file with all the filenames that I want to process
- I want a script that goes trough all those... (7 Replies)