Anyone have a shell script to remove controlM character from all the files in a directory

Member Avatar
Member Avatar
+0 forum 14

Hi, i want to delete a column from a file. the file is like : 1|2|3|4|5|6|7|8|9|0 1|2|3|4|5|6|7|8|9|0 1|2|3|4|5|6|7|8|9|0 1|2|3|4|5|6|7|8|9|0 1|2|3|4|5|6|7|8|9|0 1|2|3|4|5|6|7|8|9|0 if i want to remove any column the outout should be like ( suppose 4): 1|2|3|5|6|7|8|9|0 1|2|3|5|6|7|8|9|0 1|2|3|5|6|7|8|9|0 1|2|3|5|6|7|8|9|0 1|2|3|5|6|7|8|9|0 1|2|3|5|6|7|8|9|0 i have used swk command, but its not giving the desired output: its giving some extra delimeters: awk 'BEGIN{FS=OFS="|"}{$4="";gsub(FS,"")}1' file please help

Member Avatar
Member Avatar
+0 forum 12

Hi all, I would like to replace new lines with "<BR>" in a text file. I'm executing the following line in Powershell: `[regex]::Replace((Get-Content "testfile.txt"), "\.``n", ".<BR>", "Singleline")` The contents of testfile.txt: Some text here for paragraph one. More text for paragraph two.

Member Avatar
Member Avatar
+0 forum 1

I don't understand why my function is not giving similar output as the first example of powershell code PS C:\Users\shane> $x = 3 PS C:\Users\shane> $y = 6 PS C:\Users\shane> $a = $x + $y PS C:\Users\shane> Write-Host "The answer is $a" The answer is 9 My function using similar logic PS C:\Users\shane> Function Add ($x, $y){ >> $a = $x + $y >> Write-Host “The Answer is $a” >> } >> PS C:\Users\shane> add 3,6 The Answer is 3 6 I would expect the output to say "The Answer is 9" instead of "The Answer is 3 6" What …

Member Avatar
Member Avatar
+0 forum 1

Hello, I have written the basic shell script "myscript.sh", which prints Hello World. I want to call this script using PL/SQL. Please let me know the procedure(steps) for the same. Thank you.

Member Avatar
Member Avatar
+0 forum 3

Hey guys, I have this script that does count one year of files, 2014, but when it comes to this year, everything messes up. How could I count properly for each year in the same script ? In the attached screenshot it's obvious that I would only need 2014 - all of the months and from 2015 only January, but .... how ? Thanks in advance! ls -la | awk -v year="$(date "+%Y")" 'BEGIN { split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec", month, " ") for (i=1; i<=12; i++){ mdigit[month[i]]=i } } !/^-/{next} $8 ~ …

Member Avatar
Member Avatar
+0 forum 4

I very new to C Shell. I am trying to do is read from Command line. Find the if the file is zip, .txt, symbloic link,pipe, unknow (if file is not zip, txt, sy....) here is what I what got so far. I am very stuck atm Please help me out : #!/bin/csh if ( "`echo ${1} | cut -d'.' -f2`" == "zip" ) then echo $1 is a zip file else echo sorry, $1 is not a zip file endif

Member Avatar
Member Avatar
+0 forum 1

Hi All, I'm working on a script which has a primary function to look for jpg files. I can get it to work if the folder path is just my desktop but if I try the start of the path to be C:\ it errors out. Right now the error has to do with the MID function but I know it is because of me trying to go through all of C:\. See the code below and if you can assist me I would really appreciate it. Set objFSO = CreateObject("Scripting.FileSystemObject") 'objStartFolder is where you enter the folder path string …

Member Avatar
Member Avatar
+0 forum 4

Hello! I am normally in the PHP / Web Development section of DaniWeb. It's a pleasure to finally have a reason to check out other sections of DaniWeb! So, I am logged in as root at the Command Line Interface over SSH - on Debian 7 Wheezy running on a BeagleBone Black Rev B6 - and I am running into an unexpected problem. I have made a folder ~/folder/pythonversion I go to ~/folder/ I type "ls -l python*/" I expect ls -l to match the "python" part, and match "version" to the * - therefore returning the pythonversion folder name …

Member Avatar
Member Avatar
+0 forum 4

Hi Team, I have a file which contain following data like BKP0000032183140217000019 053IGZYEVSDOX .........field 2....... field3.....field4..... BKP0000032284140217000019CCTP1220 ............... BKP0000032384140217000019CA ..................... each line has 5 fields Now using shell script i am trying to extract field 4 based on condition that line start with BKP and contain code 84 and CA or CC code grep -A12 " RFND " xfer_BSPDe | grep "^BKP" >file2.txt While read line do awk '{if((substr($1,12,2)==84) && (substr($1,26,2)=='CC' || substr($1,26,2)=='CA') ) print $4;else print "0"}' done<file2.txt it is printing 0 only . any help is appreciable.

Member Avatar
Member Avatar
+0 forum 3

Hey all, I was wondering if a web page could be opened in Mozilla Firefox using a shell script!..I haven't given it a try as yet...I will also try and if I find a a solution I'll definitely put it up....Till then if someone finds a solution or knows it already can also put it up here.... Till then, Cheers!!! Thanx, Shreerang Patwaardhan.

Member Avatar
Member Avatar
+0 forum 5

Hi all, I am having a play around with batch files but have hit a stumbling block. The file returns the contents of an image folder and outputs the results in html format as such: Thumbnail - Filename (usable link) - Creation Date - Modified Date Please bear in mind that this is a work in progress and may look a little messy. What I am stuck on is that the Creation Date variable contains the Creation Time which is also output in the result. I have no need for the Creation Time of the file to be shown and …

Member Avatar
Member Avatar
+0 forum 3

echo ${NUM:0:2} The above is just an example of the kind of code I'M using. I need a way to represent the end of the string. Is there a way to start from the right side of a line of text instead of the left? What I'M trying to do here is grab the last three digits on end, then the next three and so on. NUM in this case will be a user input so there is no way to hard code the end position. Thanks.

Member Avatar
Member Avatar
+0 forum 3

I'm trying to get the date to work properly. The time is 5 pm (1700 hours) now i.e. evening but it always says morning. Here's my code currenthour="$(date "+ %-H")" echo $currenthour if [ $currenthour -gt '12' ] && [ $currenthour -lt '16' ]; then currenttimeofday="Afternoon" elif [ $currenthour -gt '16' ] && [ $currenthour -lt '1' ]; then currenttimeofday="Evening" else currenttimeofday="Morning" fi echo $currenttimeofday

Member Avatar
Member Avatar
+0 forum 1

xhi, my task is to make a script, which displays the string read from console input in the form of 1 letters / line only. my code looks like this so far read string hossz=`expr length "$string"` for i in `seq 1 $hossz` do echo `expr substr $string $i 1` done my problem is that if the string contains spaces, i only get a bunch of expr syntax errors, else its working correctly. i tried using the tr command to change the spaces into "\n" but i failed to do that too :(. also tried googleing but i couldnt find …

Member Avatar
Member Avatar
+0 forum 2

![3a451fbd93eb17f84f06c7ac648bdcab](/attachments/small/2/3a451fbd93eb17f84f06c7ac648bdcab.PNG "align-left") I need to create this program for class. I'm not looking for the answer. I'm simply confused on how to create a batch file where I input a number and it gives me an option. Would I use the IF command if so how would I do it. My teacher is awful and he doesn't explain anything. Here is what I got so far @ECHO OFF ECHO This BAT file will display the symbol of your choice Echo. ECHO 1. Stars ECHO 2. Dollars ECHO 3. Pluses ECHO e. Exit Program ECHO. ECHO Enter your choice (1, 2, …

Member Avatar
Member Avatar
+0 forum 9

hello, I created a awk program to work witha data file to output a table and subtotal the rows and total up the collums and average I got it to work but when i added a presentation header before my totals go away. working code so far ------ can be viewed at http://cwl-host.com/linux/wtest and when i added the presentation headder my totals went away http://cwl-host.com/linux/test im using awk -f wtest datafile.dat

Member Avatar
Member Avatar
+0 forum 1

Hi, I need to fetch mail body from the local stored mailbox file. I'm using fetchmail and procmail to download emails from IMAP server and filterout unwanted one. From the list of emails, I want to process one by one and get their body and store it. the format of mailbox file would be something like this From hemanshu Fri Aug 30 11:25:25 2013 Return-Path: <hemanshu@example.com> Received: from mailgate.example.com [xx.xx.xx.xx] by lt-hemanshu.client.example.com with IMAP (fetchmail-6.3.22) for <hemanshu@localhost> (single-drop); Fri, 30 Aug 2013 11:25:25 -0400 (EDT) Received: via tmail-2000(13) for user1; Tue, 27 Aug 2013 16:27:25 -0400 (EDT) Received: from mail.example.com …

Member Avatar
Member Avatar
+0 forum 1

I am currently trying to use the "find" command with symbollic links created by a tcl script that are pointing at another file in another directory (RH5). My script is written in bash, however: find /home/directory/subdirectory -name *.gz -type f -printf '%T@ %p\n' | sort -n | tail -n 1 | awk'{print $1}' I use this as my go to line to find the epoch time of the latest file that populated the directory given the search criteria that I can change as I need. For some reason, it doesn't work with link files. It returns no results. I know …

Member Avatar
Member Avatar
+0 forum 2

Hi I have a linux server with mysql installed.There is some data in mysql tables. Also.I have a .csv file (not from the aforementioned database) I need to compare the data in the database nad the .csv and print out the difference. I tried writing a shell script for that but I was unsuccessful. I need to ask if there's any way I can export the data from mysql tables to .csv file format and use the diff command to see the comparison of the generated file and the file I had initially. ~thanks

Member Avatar
Member Avatar
+0 forum 3

I dont know what caused such a filenames and i am not able to remove these files. $ ls A????cd new????cat> >> A A????cd new????cat ????A Desktop Downloads file.sh menu.sh new new1.sh new.sh Pictures rename Videos A????cd new????cat |A A?echo A Documents even.sh filetest.sh Music new1.lst new.lst palindrome.sh Public Templates vowel.sh Please Suggest

Member Avatar
Member Avatar
+0 forum 8

How to find the difference of two files and get a 3rd file with the newer information alone. for example: There are two files file1 and file2 **file1** apple mango pear **file2** apple mango pear cat and dog I need a file with **fileout** cat and dog how to achieve this with diff and patch. are there any other way? note: the files have millions of records.

Member Avatar
Member Avatar
+0 forum 6

Why is it that no matter how long I put the sleep command or loop, cat is unable to read the file, even though the file already exsists? Is there any way of reliably waiting for the whois to finish, write to file and then read that the file exsists?? Could this have anything to do with using network mapped diretories or using cygwin? whoisDoc=`whois -H "$query" > "/cygdrive/location/whois$query"` netName=" " orgName=" " Country=" " #Wait for whois to be written to disk escape=0 cat whois$query > /dev/null timer=$? while [ $timer -ne 0 ];do sleep 5 escape=$((escape+1)) if [ …

Member Avatar
Member Avatar
+0 forum 2

i have an awk script and in the end section i create my table data with printf and i want to sort it so i used pipe then sort i am calling it like this awk -f awkscript file in bash i can get it to work the way i want using END{ for... printf "%d\t%d\t%d\n",x, a[x],b[x] | "sort -t $'\t' -k3,3rn -k2,2rn" but this does not work bourne shell on solaris. as an experiment i did this printf "%d\t%d\t%d\n",x, a[x],b[x] > "testfile" then on the shell i did this cat testfile | sort -t "`printf '\t'`" -k3,3nr -k2,2rn and …

Member Avatar
Member Avatar
+0 forum 1

Hello everyone. I am trying to compile this simple code using gcc under Cygwin terminal. //A function that just returns a value// int my_function() { return 0xbaba; } I saved the code as basic.c I issue the command $gcc basic.c in the Cygwin terminal And I get the error: gcc: error: spawn: No such file or directory I already had enough trouble installing GCC under Cygwin. Cant figure out what this means. Please Help! Thanks in Advance!

Member Avatar
Member Avatar
+0 forum 2

vi is basically used independently .....but what if vi commands are used in shell script ? I am trying to accomplish functionality of mv command using a shell script. what I want is to yank whole text of one file1 and paste it in file2. this all should happen in Shell Script. So far I have dont following script. #!/bin/bash #file.sh echo -e "\n\t|------------------ File Transfer -----------------------|" while [ "$ch" != "n" ] do echo -e "\nEnter directory" read dir echo -e "\nEnter filename" read flnam if [ -d $dir ] then if [ -e $flnm ] then vi $flnm …

Member Avatar
Member Avatar
+0 forum 1

I'M wanting to write my own command/script for compiling my c++ files. I use g++ -g -Wall filename.cpp -o filename I'M trying to figure out how I can trip of the last four characters (.cpp) from a string. Any ideas?

Member Avatar
Member Avatar
+0 forum 4

i have 2 files, one file created on Windows and another was made on Ubuntu, i want to use this command: comm -12 file1 file2 how do i do that?

Member Avatar
Member Avatar
+0 forum 2

i got a string var=96.33% from 120 how do i get 96.33 from $var?

Member Avatar
Member Avatar
+0 forum 6

i want to find the total space used for the files owned by me from my current directory. i have du -sh `find ./ -user $USER -type f` which gives 8.0K ./.a 8.0K ./t 4.0K ./cat/A 4.0K ./a using -s has no effect. using du -sh by itself includes the space for files not owned by me and also includes space used by folders themselves. I want to be able to add all of the above and displayed in readable format automatically. At this stage i am happy to include the space used for folders or not, doesnt matter. Any …

Member Avatar
Member Avatar
+0 forum 2

The End.