Need to make change in a file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Need to make change in a file
# 1  
Old 10-23-2012
Need to make change in a file

i want to make null file using awk..

Last edited by Adhi; 10-24-2012 at 12:54 PM..
# 2  
Old 10-23-2012
As suggested in the below thread, can you show your work ?

https://www.unix.com/unix-dummies-que...work-file.html
# 3  
Old 10-23-2012
Really i don't what to use here...

---------- Post updated at 11:14 AM ---------- Previous update was at 11:03 AM ----------

For the first query, I used

Code:
awk -F ' ' '{print $3}' adg | sed 's/[0]*/ /'

But now am getting third column only.. How can i get the whole..
# 4  
Old 10-23-2012
Code:
echo '00510010            0000000471           000000000482.90 000000005855.49' | awk '{gsub("^00*","",$3);gsub("^00*","",$4)}1' OFS=','

# 5  
Old 10-23-2012
Code:
$ echo '00510010            0000000471           000000000482.90 000000005855.49' | awk '{$3=$3+0;$4=$4+0}1' OFS=','
00510010,0000000471,482.9,5855.49

# 6  
Old 10-23-2012
Quote:
Originally Posted by itkamaraj
Code:
$ echo '00510010            0000000471           000000000482.90 000000005855.49' | awk '{$3=$3+0;$4=$4+0}1' OFS=','
00510010,0000000471,482.9,5855.49

you may loose precision (if it's important for the OP).
# 7  
Old 10-23-2012
Quote:
Originally Posted by vgersh99
Code:
echo '00510010            0000000471           000000000482.90 000000005855.49' | awk '{gsub("^00*","",$3);gsub("^00*","",$4)}1' OFS=','

Its working perfectly.. But what is the purpose of using 1??? and OFS=','
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Make change to variable value inside of awk script

Hello, I have text data that looks like this, Mrv16a3102061815532D 6 6 0 0 0 0 999 V2000 -0.4018 1.9634 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 -1.1163 1.5509 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 -1.1163 0.7259 ... (9 Replies)
Discussion started by: LMHmedchem
9 Replies

2. Shell Programming and Scripting

Add character to specific columns using sed or awk and make it a permanent change

Hi, I am writing a shell script where I want that # should be added in all those lines as the first character where the pattern matches. file has lot of functions defined a.sh #!/bin/bash fn a { beautiful evening sunny day } fn b { } fn c { hello world .its a beautiful day ... (12 Replies)
Discussion started by: ashima jain
12 Replies

3. UNIX for Dummies Questions & Answers

Will authconfig make permanent change or lost after reboot?

Hi, I made following configuration to create user directory: # authconfig --enablemkhomedir --update But the directory is created as permission 755, I'd like to modify the script to change directory access permission to 700, where is the script which copies /etc/skel to /home... (0 Replies)
Discussion started by: hce
0 Replies

4. UNIX for Dummies Questions & Answers

Cannot make sudoers change work

I logged in as root and visudo'd /etc/sudoers. I found several users with the username ALL=(ALL) ALL entries and added an account after the last one. Saved the file. When the user logs in and does "sudo su -" they are prompted for their password and then told they are not in the sudoers file.... (8 Replies)
Discussion started by: rpm_on_lnx
8 Replies

5. Shell Programming and Scripting

ksh; Change file permissions, update file, change permissions back?

Hi, I am creating a ksh script to search for a string of text inside files within a directory tree. Some of these file are going to be read/execute only. I know to use chmod to change the permissions of the file, but I want to preserve the original permissions after writing to the file. How can I... (3 Replies)
Discussion started by: right_coaster
3 Replies

6. Programming

using dbx: I can't make it watch a variable change?! Help, please!

(I have mentioned about this situation and arisen problems in another thread: Is there a limit for a code line length in C?, but those questions are OffTop for that subject; so I open a new topic, here.) The main problem is that I have some situation in my program where memory has been changed... (2 Replies)
Discussion started by: alex_5161
2 Replies

7. UNIX for Dummies Questions & Answers

how to change the destination directory of a make install

Hi there, I'm installing the sleuthkit from sources (because the debian package is crap). So I go threw the process of wget + tar + configure + make + make install. At the end, all the executables and libraries are in /usr/local/bin/, /usr/local/lib/, /usr/local/share/... How can I do to... (3 Replies)
Discussion started by: chebarbudo
3 Replies

8. Programming

makeutility: how to get the make-file name inside of the make-file?

How I can get the current make-file name in a make-file So, if I run make with specified file:make -f target.mak is it possible to have the 'target' inside of the that 'target.mak' from the file name? (2 Replies)
Discussion started by: alex_5161
2 Replies

9. UNIX for Dummies Questions & Answers

How to make ulimit change permanent

ulimit -a gives the following output:$ulimit -a time(seconds) unlimited file(blocks) 2097152 data(kbytes) 131072 stack(kbytes) 16384 memory(kbytes) unlimited coredump(blocks) 32768 nofiles(descriptors) 400 vmemory(kbytes) 147456 Abot output... (3 Replies)
Discussion started by: nervous
3 Replies

10. Shell Programming and Scripting

How to make the same change in multiple shell scripts?

I would like to make the same change in multiple shell script files and would like to know if anyone can be of some help? I would appreciate it. (4 Replies)
Discussion started by: rdakhan
4 Replies
Login or Register to Ask a Question