06-16-2014
Quote:
Originally Posted by
Corona688
$0 is a special variable in awk which means "the entire line".
NF is a special variable which means "the number of fields", i.e. columns.
So we set the entire line with its current contents, plus the PREV contents, and if there's enough fields, print it. Otherwise, save it all in PREV for next time.
Nice! Thank you again!
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
hi
how do i manipulate .csv file to add an extra row after each row using shell script?
I need a blank line added for each 1000 records in my file?
I will then need to copy and paste some data in the blank row created.
thanks 4 ur support
neil (3 Replies)
Discussion started by: neil546
3 Replies
2. Shell Programming and Scripting
Hello,
W/in the script I'm working on, I have a need to take a column from a file, and format it so I can have a variable that will egrep for & invert the regex from another file.
My solution is this:
VAR=`awk -F, '{print $2}' $FAIL | sed 's/-i/\|/g'`
VAR2=`echo $VAR | sed 's/... (5 Replies)
Discussion started by: Matthias03
5 Replies
3. UNIX for Dummies Questions & Answers
Open to a sed/awk/or perl alternative so that i can stick command into my bash script.
This is a problem I resolve using a combination of cut commands - but that is getting convoluted. So would really appreciate it if someone could provide a better solution which basically replaces all... (3 Replies)
Discussion started by: svn
3 Replies
4. Shell Programming and Scripting
Name,,,,,,,,,,,,,,,,,,,,Domain,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Contact,Phone,Email,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Location
-----------------------,------------------------------------------------,-------,-----,---------------------------------,------------------------------------
----... (1 Reply)
Discussion started by: sreenath1037
1 Replies
5. Shell Programming and Scripting
I am relatively new to this forum and Unix scripting.
ksh script:
part 1 :will call a PL\SQL program will create 3 CSV file at the unix directory.
part 2 : will sftp the files to the EFT server.
Once the EFT server receives these file , it will transfer them to a shared windows folders.
... (3 Replies)
Discussion started by: developerpa
3 Replies
6. Shell Programming and Scripting
Trying in this forum. Not sure if it is permitted.... but in need of help.
Please find the requirements in the below link.
https://www.unix.com/unix-dummies-questions-answers/191503-add-extra-commas-csv-file-2.html#post302665179
Thanks in Advance. (1 Reply)
Discussion started by: chillblue
1 Replies
7. UNIX for Dummies Questions & Answers
Hi ,
Based on my previous requirement the code works fine for comma as delimiter.
Now my Req is widened up a bit ..
There will be two set of files .. one with comma as delimiter and other with semi-colon ; as delimiter.
Second Sample file.
With Double Quotes (Semi-Colon... (1 Reply)
Discussion started by: chillblue
1 Replies
8. UNIX for Dummies Questions & Answers
Hi All,
I got this requirement to process a complex CSV file.
Eg File.
Line 1: Name:,XYz
Line 2: Age:,15
Line 3: Grade:,7
Line 4:
Line 5: English, Maths, Science,Spanish
Line 6:10,11,13,14
As you can see the maximum column is 4 . The file i need to make is
Line 1: Name:,XYz,,... (12 Replies)
Discussion started by: chillblue
12 Replies
9. Shell Programming and Scripting
Hi Tech Guru,
I have a test file as below , which needs some more fields to be populated randomly :
dks3243;12;20130823;1420;25m;0;syt
dks3243;rocy;10
dks3243;kiop;18
sde21p4;77;20151210;8479;7py;9;vfr
sde21p4;temp;67
sfq6i01;12;20120123;3412;4rd;7;jui
sfq6i01;uymk;90
sfq6i01;kiop;51
... (8 Replies)
Discussion started by: Lokesha
8 Replies
10. Shell Programming and Scripting
Hello Experts,
I got a requirement i have a input file which am getting from different source,Now i want to add extra 3 columns to this file like BASE,ACTUAL and DATE.
Input File Looks like
QUAL CHGE TYP LAW COM1 COM2
A 1 X SED HO ASE
B 3 Z CDE SE ... (5 Replies)
Discussion started by: ahmed.vaghar
5 Replies