Change file content 4 column to one Column using script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Change file content 4 column to one Column using script
# 1  
Old 03-02-2012
Change file content 4 column to one Column using script

Hi Gurus,

I have file content sample:

,5113955056,,TAgent-Suspend
,5119418233,,TAgent-Suspend
,5102119078,,TAgent-Suspend

filenames 120229H5_suspend, 120229H6_unsuspend

I receive those files one of directory /home/temp/

I need following:

HTML Code:
1. Backup first /home/temp/ file to /home/bak

2. File content will be changed to only one column:

5113955056
5119418233
5102119078

3. File *_suspend, *_unsuspend will be transferred to following directories:

/home/suspend/*_suspend
/home/unsuspend/*_unsuspend


4. That Script will put in Crontab for doing the operation 4 times a day. Checking /home/temp file, if present do the above operation.

5. Need a output log of that script: File processed done or No file found.
Need you help to develp the script please.
# 2  
Old 03-02-2012
And your attempt to arrive at a solution to the problem would be?
# 3  
Old 03-02-2012
actually I am new to script. Main issue is Step: 2 "File content will be changed to only one column"

I need help to write the script.
# 4  
Old 03-02-2012
Hi thepurple,

It's not clear for me.

For example, step 1: You have two files

Quote:
/home/temp/120229H5_suspend
/home/temp/120229H6_unsuspend
and want to copy them to

Quote:
/home/bak/120229H5_suspend
/home/bak/120229H6_unsuspend
Is like this?

And step 2, content of which file?

Regards,
Birei
# 5  
Old 03-03-2012
content of 120229H5_suspend which is in 4 column. Need to make it 1 column
# 6  
Old 03-03-2012
You can use
Code:
cut -d, -f2 infile > outfile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to insert data into black column( Secound Column ) in excel (.XLSX) file using shell script?

Source Code of the original script is down below please run the script and try to solve this problem this is my data and I want it column wise 2019-03-20 13:00:00:000 2019-03-20 15:00:00:000 1 Operating System LAB 0 1 1 1 1 1 1 1 1 1 0 1 (5 Replies)
Discussion started by: Shubham1182
5 Replies

2. Shell Programming and Scripting

Change data in one column with data from another file's column

Hello, I have this file outputData: # cat /tmp/outputData __Capacity^6^NBSC01_Licences^L3_functionality_for_ESB_switch __Capacity^2100^NBSC01_Licences^Gb_over_IP __Capacity^1837^NBSC01_Licences^EDGE_BSS_Fnc __Capacity^1816^NBSC01_Licences^GPRS_CS3_and_CS4... (1 Reply)
Discussion started by: nypreH
1 Replies

3. Shell Programming and Scripting

Sort a file content using one column

Hello All, I have a file which have content as below. 03/09/2014 10:35 AM 618 Admin\rick pqr_ klm2_pog12_20140309_c.xlsx 03/10/2014 10:35 AM 618 user\test01 mplz_ fgh2_lal12_20140310_c.xlsx 03/17/2014 10:35 AM 618 Admin\vick abc_ xyz2_bc12_20140317_c.xlsx 03/18/2014 ... (2 Replies)
Discussion started by: kumar30213
2 Replies

4. Shell Programming and Scripting

Change column to row base on column 2

Hi Guys, Input.txt L194 A -118.2 L194 B -115.1 L194 C -118.7 L196 A 0 L196 C 0 L197 A -111.2 L197 B -118.9 L197 C -119.9 L199 A -120.4 L199 B -119.9 ... (2 Replies)
Discussion started by: asavaliya
2 Replies

5. Shell Programming and Scripting

awk or sed: change the color of a column w/o screwing up column spacing

Hey folks. I wrote a little awk script that summarizes /proc/net/dev info and then pipes it to the nix column command to set up column spacing appropriately. Here's some example output: Iface RxMBytes RxPackets RxErrs RxDrop TxMBytes TxPackets TxErrs TxDrop bond0 9 83830... (3 Replies)
Discussion started by: ryran
3 Replies

6. Shell Programming and Scripting

Help with replace column one content based on reference file

Input file 1 testing 10 20 1 A testing 20 40 1 3 testing 23 232 2 1 testing 10 243 2 . . Reference file 1 final 3 used . . Output file (1 Reply)
Discussion started by: perl_beginner
1 Replies

7. Shell Programming and Scripting

Match column 3 in file1 to column 1 in file 2 and replace with column 2 from file2

Match column 3 in file1 to column 1 in file 2 and replace with column 2 from file2 file 1 sample SNDK 80004C101 AT XLNX 983919101 BB NETL 64118B100 BS AMD 007903107 CC KLAC 482480100 DC TER 880770102 KATS ATHR 04743P108 KATS... (7 Replies)
Discussion started by: rydz00
7 Replies

8. Shell Programming and Scripting

Need to convert the content of file into COLUMN (To export into excel)

I have multiple condition in file as below. MONITOR "ALERT_INFO" DESCRIPTION "Triggered when informational Netware alert occured" MAXTHRESHOLD 95 SEVERITY Normal MONITOR "ALERT_MAJOR" DESCRIPTION "Triggered when major Netware alert occured" MAXTHRESHOLD SEVERITY Major I need to... (6 Replies)
Discussion started by: velocitnitin
6 Replies

9. Shell Programming and Scripting

Change names in a column based on the symbols in another column

If the 4th column has - sign then the names in 3rd column has to change to some user defined names (as shown in output). Thanx input1 1 a aaaaa + 2 b bbbbb + 3 c ccccc + 4 d ddddd + 5 e eeeee + 6 f xxxxx + 8 h hhhhh +... (8 Replies)
Discussion started by: repinementer
8 Replies

10. Shell Programming and Scripting

Changing one column of delimited file column to fixed width column

Hi, Iam new to unix. I have one input file . Input file : ID1~Name1~Place1 ID2~Name2~Place2 ID3~Name3~Place3 I need output such that only first column should change to fixed width column of 15 characters of length. Output File: ID1<<12 spaces>>Name1~Place1 ID2<<12... (5 Replies)
Discussion started by: manneni prakash
5 Replies
Login or Register to Ask a Question