Sponsored Content
Top Forums Shell Programming and Scripting Shell scripting:from text file to CSV Post 302822579 by kraterions on Tuesday 18th of June 2013 01:15:21 AM
Old 06-18-2013
Shell scripting:from text file to CSV

Hello friends,
I have a file as follows:

Code:
"empty line" 
content1 
content2 
content3

content1 
content2 
content3  

content1 
content2 
content3



It starts with an empty line
,

how can i get a csv like this:

Code:
content1,content2,content3 
content1,content2,content3 
content1,content2,content3

many thanks for your attention and big help.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Shell scripting adding text to top of file

Hi this is quite simple i am sure but without using awk or sed i need to add text to the top of a file this is what i have got so far #!bin/bash echo "Add text to top of file" read line echo $line >> file1 This adds the text to the bottom of the file can some1 please help cheers (7 Replies)
Discussion started by: meadhere
7 Replies

2. Shell Programming and Scripting

exporting number into .csv file in text form (no other extra charc) from shell script

I have written a k shell program which is executing a sql and exporting data in numeric form like 0412323444 into .csv file. the problem i am facing is that , the data is coming in excel formatted in scientific form like 4.1+E08,while my requirement is to store data as such 0412323444 in excel ( no... (5 Replies)
Discussion started by: Deepak_Rastogi
5 Replies

3. Shell Programming and Scripting

How to insert a sequence number column inside a pipe delimited csv file using shell scripting?

Hi All, I need a shell script which could insert a sequence number column inside a dat file(pipe delimited). I have the dat file similar to the one as shown below.. |A|B|C||D|E |F|G|H||I|J |K|L|M||N|O |P|Q|R||S|T As shown above, the column 4 is currently blank and i need to insert sequence... (5 Replies)
Discussion started by: nithins007
5 Replies

4. Shell Programming and Scripting

XML to Text file Parsing Using shell scripting

Hi folks, Need some help with XML to text file parsing , the following is the content of the XML File. <xn:SubNetwork id="SNJNPRZDCR0R03"> <xn:MeContext id="PRSJU0005"> <xn:VsDataContainer id="PRSJU0005"> <xn:attributes> ... (6 Replies)
Discussion started by: tech_frk
6 Replies

5. Solaris

XML to Text file Parsing Using shell scripting

Hi, I want to parse an XML File using Shell Script preferably by using awk command, I/P file is : <gn:ExternalGsmCell id="016P3A"> <gn:attributes> <gn:mnc>410</gn:mnc> <gn:mcc>310</gn:mcc> <gn:lac>8016</gn:lac> ... (2 Replies)
Discussion started by: tech_frk
2 Replies

6. UNIX for Dummies Questions & Answers

Shell script to read lines in a text file and filter user data Shell Programming and Scripting

sxsaaas (3 Replies)
Discussion started by: VikrantD
3 Replies

7. Shell Programming and Scripting

How to calculate avg values of csv file using shell scripting .?

hi all i have a reporting work and i want it to be automated using shell scripting kindly let me know how can i make that possibe . eg data are :... (2 Replies)
Discussion started by: Avinash shaw
2 Replies

8. Shell Programming and Scripting

Need a piece of shell scripting to remove column from a csv file

Hi, I need to remove first column from a csv file and i can do this by using below command. cut -f1 -d, --complement Mytest.csv I need to implement this in shell scripting, Whenever i am using the above command alone in command line it is working fine. I have 5 files in my directory and... (3 Replies)
Discussion started by: Samah
3 Replies

9. Shell Programming and Scripting

Delete all CONSECUTIVE text lines from file shell scripting

Hi I have a text file like below. THe content of the text will vary. Entire text file have four consecutive lines followed with blank line. I want to delete the occurrence of the two consicutive lines in the text file. I don't have pattern to match and delete. Just i need to delete all... (5 Replies)
Discussion started by: RJSKR28
5 Replies

10. Shell Programming and Scripting

Read csv file, convert the data and make one text file in UNIX shell scripting

I have input data looks like this which is a part of a csv file 7,1265,76548,"0102:04" 8,1266,76545,"0112:04" I need to make the output data should look like this and the output data will be part of text file: 7|1265000 |7654899 |A| 8|12660000 |76545999 |B| The logic behind the... (6 Replies)
Discussion started by: RJG
6 Replies
USB_MODESWITCH(1)					      General Commands Manual						 USB_MODESWITCH(1)

NAME
usb_modeswitch - switch mode of "multi-state" USB devices SYNOPSIS
usb_modeswitch [-heWQDIvpVPmM23rwdHSOBGTNALnsRiuagft] [-c filename] DESCRIPTION
Several new USB devices have their proprietary Windows drivers onboard, most of them WAN dongles. When plugged in for the first time, they act like a flash storage and start installing the Windows driver from there. If the driver is already installed, it makes the storage device disappear and a new device, mainly composite with modem ports, shows up. On Linux, in most cases the drivers are available as kernel modules, such as "usbserial" or "option". However, the device shows up as "usb- storage" by default. usb_modeswitch can send a provided bulk message (most likely a mass storage command) to the device which is known to initiate the mode switching. In some cases, USB control commands are used for switching. These cases are handled by custom functions, and no bulk message needs to be provided. Usually, the program is distributed with a set of configurations for many known devices, which in combination with a wrapper script launched from the udev daemon allows a fully automatic handling of a device upon insertion. OPTIONS
This program follows the usual GNU command line syntax, with long options starting with two dashes ('--'). A summary of options is included below. -h --help Show summary of options. -e --version Print version information and exit -v --default-vendor NUM Vendor ID to look for (mandatory), usually given as hex number (example: 0x12d1). Each USB device is identified by a number officialy assigned to the vendor by the USB association and a number for the respective model (product ID) chosen by the vendor -p --default-product NUM Product ID to look for (mandatory) -V --target-vendor NUM Target vendor ID. When given will be searched for and detected initially for information purposes. If success checking (option -s) is active, providing target IDs (vendor/product) or target class is recommended -P --target-product NUM Target product ID -b --busnum NUM -g --devnum NUM If bus and device number are provided, the handling of a specific device on a specific USB port is guaranteed, in contrast to using only the USB ID. This is important if there are multiple similar devices on a system -C --target-class NUM Target Device Class according to the USB specification. Some devices keep their original vendor/product ID after successful switching. To prevent them from being treated again, the device class can be checked. For unswitched devices it is always 8 (storage class), for switched modems it is often 0xff (vendor specific). In composite modes, the class of the first interface is watched -m --message-endpoint NUM A specific endpoint to use for data transfers. Only for testing purposes; usually endpoints are determined from the device attributes -M --message-content STRING A bulk message to send as a switching command. Provided as a hexadecimal string -2, -3 --message-content2, --message-content3 STRING Additional bulk messages to send as switching commands. Provided as hexadecimal strings. When used with mass storage commands, setting --need-response is strongly advised to comply with specifications and to avoid likely errors -w --release-delay NUM After issuing all bulk messages, wait for NUM milliseconds before releasing the interface. Required for some modems on older systems (especially after an EJECT message) -n --need-response Read the response (command status wrapper) to a mass storage command transfer. Some devices have trouble switching if the response is not read; most are disappearing right away. When sending multiple mass storage commands with -2 and -3, this may need to be set to avoid transfer errors -r --response-endpoint NUM Try to read the response to a storage command from there if option -n is active. Only for testing purposes; usually endpoints are determined from the device attributes -d --detach-only Just detach the current driver. This is sufficient for some early devices to switch successfully. Otherwise this feature can be used as a 'scalpel' for special cases, like separating the driver from individual interfaces -H --huawei-mode Send a special control message used by older Huawei devices -S --sierra-mode Send a special control message used by Sierra devices -G --gct-mode Send a special control message used by GCT chipsets -T --kobil-mode Send a special control message used by Kobil devices -T --sequans-mode Send a special control message used by Sequans chipset -T --mobileaction-mode Send a special control message used by the MobileAction device -B --qisda-mode Send a special control message used by Qisda devices -O --sony-mode Apply a special sequence used by Sony Ericsson devices. Implies option --success -L --cisco-mode Send a sequence of bulk messages used by Cisco devices -R --reset-usb Send a USB reset command to the device. Can be combined with any switching method or stand alone. It is always done as the last step of all device interactions. Few devices need it to complete the switching; apart from that it may be useful during testing -c --config FILENAME Use a specific config file. If any ID or switching options are given as command line parameters, this option is ignored. In that case all mandatory parameters have to be provided on the command line -f --long-config STRING Provide device details in config file syntax as a multiline string on the command line -t --stdinput Read the device details in config file syntax from standard input, e.g. redirected from a command pipe (multiline text) -Q --quiet Don't show progress or error messages -W --verbose Print all settings before running and show libusb debug messages -D --sysmode Changes the behaviour of the program slightly. A success message including the effective target device ID is put out and a syslog notice is issued. Mainly for integration with a wrapper script -s --success NUM After switching, keep checking for the result up to max. NUM seconds. If target IDs or target class were provided, their appear- ance indicates certain success. Otherwise the disconnection of the original device is rated as likely proof -I --no-inquire do not obtain SCSI attributes from device (default is on). For proper identification of differing devices the attributes of the storage part provide valuable information. This is not needed for devices that are known and supported -i --interface NUM Select initial USB interface (default: 0). Only for testing purposes -u --configuration NUM Select USB configuration (applied after any other possible switching actions) -a --altsetting NUM Select alternative USB interface setting (applied after switching). Mainly for testing AUTHOR
This manual page was originally written by Didier Raboud (didier@raboud.com) for the Debian system. Additions made by Josua Dietze. Permis- sion is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation. The complete text of the current GNU General Public License can be found in http://www.gnu.org/licenses/gpl.txt USB_MODESWITCH(1)
All times are GMT -4. The time now is 06:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy